Browse Source

do not accet testnet addresses in bitcoin.is_address

283
ThomasV 10 years ago
parent
commit
cf5328b143
  1. 5
      lib/bitcoin.py

5
lib/bitcoin.py

@ -352,11 +352,14 @@ def is_valid(addr):
def is_address(addr):
ADDRESS_RE = re.compile('[1-9A-HJ-NP-Za-km-z]{26,}\\Z')
if not ADDRESS_RE.match(addr): return False
if not ADDRESS_RE.match(addr):
return False
try:
addrtype, h = bc_address_to_hash_160(addr)
except Exception:
return False
if addrtype != 0:
return False
return addr == hash_160_to_bc_address(h, addrtype)

Loading…
Cancel
Save