more robust commands.getprivatekeys() and bitcoin.is_segwit_address()
This commit is contained in:
parent
0da1d4853b
commit
66cce115ef
|
@ -569,7 +569,10 @@ def address_from_private_key(sec):
|
||||||
return pubkey_to_address(txin_type, public_key)
|
return pubkey_to_address(txin_type, public_key)
|
||||||
|
|
||||||
def is_segwit_address(addr):
|
def is_segwit_address(addr):
|
||||||
witver, witprog = segwit_addr.decode(NetworkConstants.SEGWIT_HRP, addr)
|
try:
|
||||||
|
witver, witprog = segwit_addr.decode(NetworkConstants.SEGWIT_HRP, addr)
|
||||||
|
except Exception as e:
|
||||||
|
return False
|
||||||
return witprog is not None
|
return witprog is not None
|
||||||
|
|
||||||
def is_b58_address(addr):
|
def is_b58_address(addr):
|
||||||
|
|
|
@ -273,6 +273,8 @@ class Commands:
|
||||||
@command('wp')
|
@command('wp')
|
||||||
def getprivatekeys(self, address, password=None):
|
def getprivatekeys(self, address, password=None):
|
||||||
"""Get private keys of addresses. You may pass a single wallet address, or a list of wallet addresses."""
|
"""Get private keys of addresses. You may pass a single wallet address, or a list of wallet addresses."""
|
||||||
|
if isinstance(address, str):
|
||||||
|
address = address.strip()
|
||||||
if is_address(address):
|
if is_address(address):
|
||||||
return self.wallet.export_private_key(address, password)[0]
|
return self.wallet.export_private_key(address, password)[0]
|
||||||
domain = address
|
domain = address
|
||||||
|
|
Loading…
Reference in New Issue