From 66cce115ef93c913d65ef5c7d781c8065f79bbaf Mon Sep 17 00:00:00 2001 From: SomberNight Date: Sun, 19 Nov 2017 23:46:59 +0100 Subject: [PATCH] more robust commands.getprivatekeys() and bitcoin.is_segwit_address() --- lib/bitcoin.py | 5 ++++- lib/commands.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bitcoin.py b/lib/bitcoin.py index fce74365a..1a4f5bb27 100644 --- a/lib/bitcoin.py +++ b/lib/bitcoin.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): diff --git a/lib/commands.py b/lib/commands.py index 6857ea9fb..0d8907d73 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -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