Browse Source

Merge pull request #3335 from SomberNight/cmd_getprivkeys

more robust getprivatekeys() and is_segwit_address()
3.0.x
ThomasV 7 years ago
committed by GitHub
parent
commit
9edffd1754
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      lib/bitcoin.py
  2. 2
      lib/commands.py

3
lib/bitcoin.py

@ -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):
try:
witver, witprog = segwit_addr.decode(NetworkConstants.SEGWIT_HRP, addr) 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):

2
lib/commands.py

@ -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…
Cancel
Save