Author

Topic: How check address for validity? (Read 4010 times)

newbie
Activity: 2
Merit: 0
October 23, 2010, 03:45:41 AM
#20
Hi,
 I am new here. wish everybody have a good time.


How to check address validity in my sql server. i am for got my address can any one help me please.
legendary
Activity: 1652
Merit: 2216
Chief Scientist
October 20, 2010, 11:33:58 PM
#19
RE: payment:
If you really feel compelled to pay, send coins to the Faucet: 15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC
LZ
legendary
Activity: 1722
Merit: 1072
P2P Cryptocurrency
October 20, 2010, 10:26:11 PM
#18
Please write bitcoin address for the payment of this work.
I think you can send him BitMail. Smiley
sr. member
Activity: 350
Merit: 252
probiwon.com
October 20, 2010, 05:24:23 PM
#17
I implemented "validateaddress" in svn r169:


$ ./bitcoind validateaddress '1P3rpbSybuGgeL1bRwCJFWbn4yBjRNQrbY'


Who bitcoind instead of bitcoin?


Please write bitcoin address for the payment of this work.
legendary
Activity: 1652
Merit: 2216
Chief Scientist
October 20, 2010, 03:33:12 PM
#16
I implemented "validateaddress" in svn r169:


$ ./bitcoind validateaddress '1P3rpbSybuGgeL1bRwCJFWbn4yBjRNQrbY'
{
    "isvalid" : true,
    "address" : "1P3rpbSybuGgeL1bRwCJFWbn4yBjRNQrbY",
    "ismine" : true
}
$ ./bitcoind validateaddress '1111111111111111111114oLvT2'
{
    "isvalid" : true,
    "address" : "1111111111111111111114oLvT2",
    "ismine" : false
}
$ ./bitcoind validateaddress 'mwFzbfqePwXUyT28e1kFVVh48uMHDsRzbi'
{
    "isvalid" : false
}

No address version number; that wasn't trivial to do, so I didn't do it.
sr. member
Activity: 350
Merit: 252
probiwon.com
October 04, 2010, 01:21:51 AM
#15
I will offer 5btc reward for this patch to be produced.

+5btc from me
hero member
Activity: 574
Merit: 507
October 03, 2010, 10:03:34 PM
#14
I will offer 5btc reward for this patch to be produced.

+5btc from me
LZ
legendary
Activity: 1722
Merit: 1072
P2P Cryptocurrency
October 02, 2010, 04:51:51 AM
#13
And what are you answering yourself? Smiley

1. Validate e-mail using regular expressions.
2. Then check domain exists for that e-mail.
Say "helo" to 25 port and you should get "250".
3. Then check that user exists at that domain.
Say "rcpt to" and you should get "550" if exists.
newbie
Activity: 2
Merit: 0
October 02, 2010, 03:51:18 AM
#12
In my work I am asking my self is there way to check    e-mail address validity. so please help.
sr. member
Activity: 350
Merit: 252
probiwon.com
September 25, 2010, 04:12:18 AM
#11
I would be trivial to add a JSON-RPC command to do that. Just use the IsValidBitcoinAddress function.

For extra credit, give an Object as the return value:

{
  'isvalid' : true,
  'ismine' : true,  # true if isvalid and you have the private key (can spend coins sent to this address)
  'version' : 0,  # ADDRESSVERSION
  'address' : '1frt6531....'    # might as well echo back the address...
}



Yes, that's option would be cool!
legendary
Activity: 1652
Merit: 2216
Chief Scientist
September 24, 2010, 09:28:43 AM
#10
I would be trivial to add a JSON-RPC command to do that. Just use the IsValidBitcoinAddress function.

For extra credit, give an Object as the return value:

{
  'isvalid' : true,
  'ismine' : true,  # true if isvalid and you have the private key (can spend coins sent to this address)
  'version' : 0,  # ADDRESSVERSION
  'address' : '1frt6531....'    # might as well echo back the address...
}

administrator
Activity: 5166
Merit: 12850
September 23, 2010, 09:58:11 PM
#9
I would be trivial to add a JSON-RPC command to do that. Just use the IsValidBitcoinAddress function.
sr. member
Activity: 350
Merit: 252
probiwon.com
September 23, 2010, 09:21:07 PM
#8
the client has already been implemented check, need just the appropriate option
As far as I understand, you want to use a switch which will return true or false...
Something like -checkaddress=bitcoin_address. We need a patch for that switch.

yes, we need Smiley
I can not write a patch, so I just tried to justify it need
LZ
legendary
Activity: 1722
Merit: 1072
P2P Cryptocurrency
September 23, 2010, 01:27:56 PM
#7
the client has already been implemented check, need just the appropriate option
As far as I understand, you want to use a switch which will return true or false...
Something like -checkaddress=bitcoin_address. We need a patch for that switch.

2nelisky, thanks for tweaked version. Wink
legendary
Activity: 1540
Merit: 1001
September 23, 2010, 12:51:21 PM
#6
you misunderstood me

the client has already been implemented check, need just the appropriate option
besides, it gives an opportunity to make small changes to the format of the address in the future if needed
and users also need address check without sending coins to make sure that the address they were told the correct

Now I don't understand you Smiley

So, how does the above pieces of code not do what you want? You don't need to send coins to check an address, you don't even need bitcoin at all, just the address. And python being very readable you can easily port that to any other language you need and know (yes, including pgplsql, assuming you have the appropriate crypto calls available)
sr. member
Activity: 350
Merit: 252
probiwon.com
September 23, 2010, 11:27:09 AM
#5
What about this? You need Python, Django and PyCrypto.

What about pgplsql? Smiley
sr. member
Activity: 350
Merit: 252
probiwon.com
September 23, 2010, 11:26:20 AM
#4
you misunderstood me

the client has already been implemented check, need just the appropriate option
besides, it gives an opportunity to make small changes to the format of the address in the future if needed
and users also need address check without sending coins to make sure that the address they were told the correct
legendary
Activity: 1540
Merit: 1001
September 23, 2010, 10:46:46 AM
#3
What about this? You need Python, Django and PyCrypto.

And what about this, which is a slightly tweaked version of that, to just depend on Python 2.5+?
Code:
#
# Stolen from gavinandresen's django field validator
#  http://bitcointalk.org/index.php?topic=1026.0
#

import re
from hashlib import sha256
import math

__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)

def b58encode(v):
  """ encode v, which is a little-endian string of bytes, to base58.   
  """

  long_value = 0L
  for (i, c) in enumerate(v[::-1]):
    long_value += (256**i) * ord(c)

  result = ''
  while long_value >= __b58base:
    div, mod = divmod(long_value, __b58base)
    result = __b58chars[mod] + result
    long_value = div
  result = __b58chars[long_value] + result

  # Pad front with Base58-encoded-0 for leading zeros:
  nPad = int((len(v)*8 / (math.log(58,2))) - len(result))

  return (__b58chars[0]*nPad) + result

def b58decode(v, length):
  """ decode v into a little-endian string of len bytes
  """
  long_value = 0L
  for (i, c) in enumerate(v[::-1]):
    long_value += __b58chars.find(c) * (__b58base**i)

  result = ''
  while long_value >= 256:
    div, mod = divmod(long_value, 256)
    result = chr(mod) + result
    long_value = div
  result = chr(long_value) + result
  if len(result) < length:
    n_pad = length-len(result)
    result = chr(0)*n_pad + result
  return result

def get_bcaddress_version(strAddress):
  """ Returns None if strAddress is invalid.  Otherwise returns integer version of address. """
  addr = b58decode(strAddress,25)
  version = addr[0]
  checksum = addr[-4:]
  vh160 = addr[:-4] # Version plus hash160 is what is checksummed
  h3=sha256(sha256(vh160).digest()).digest()
  if h3[0:4] == checksum:
    return ord(version)
  return None

def isvalid(value):
  value = value.strip()
  if re.match(r"[a-zA-Z1-9]{33,35}$", value) is None:
    return False
  return get_bcaddress_version(value) is not None
LZ
legendary
Activity: 1722
Merit: 1072
P2P Cryptocurrency
September 23, 2010, 10:30:13 AM
#2
What about this? You need Python, Django and PyCrypto.
sr. member
Activity: 350
Merit: 252
probiwon.com
September 23, 2010, 12:38:29 AM
#1
Is there a way? If not then it should be added, I think.
(I would have been easier to do it in CLI)

Why is it necessary:

Working with a database requires send queue to send coins to someone else. (You can not call the bitcoin client directly from the database - transactions can be ROLLBACKed, but sending coins is not.) Hence, the need to address customers' pre-checked against the address format.

Implement this functionality for every developer separately fraught with errors (for example, many languages not contains base58 functions ), better code to test the validity of addresses was one - in bitcoin client (or library). Besides, it gives an opportunity to make small changes to the format of the address in the future if needed.
Jump to: