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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
6 additions and
1 deletions
-
lib/bitcoin.py
-
lib/commands.py
|
|
@ -569,7 +569,10 @@ def address_from_private_key(sec): |
|
|
|
return pubkey_to_address(txin_type, public_key) |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
def is_b58_address(addr): |
|
|
|
|
|
@ -273,6 +273,8 @@ class Commands: |
|
|
|
@command('wp') |
|
|
|
def getprivatekeys(self, address, password=None): |
|
|
|
"""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): |
|
|
|
return self.wallet.export_private_key(address, password)[0] |
|
|
|
domain = address |
|
|
|