From 24af832fbdc1743bcba03a435d5f74a7d86a819b Mon Sep 17 00:00:00 2001 From: Darin Stanchfield Date: Tue, 1 Sep 2015 00:22:42 -0700 Subject: [PATCH] made sure to check if x_pubkey is valid xpub before parsing it --- plugins/keepkey.py | 15 ++++++++------- plugins/trezor.py | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/keepkey.py b/plugins/keepkey.py index d0849c01..3d44347b 100644 --- a/plugins/keepkey.py +++ b/plugins/keepkey.py @@ -283,13 +283,14 @@ class Plugin(BasePlugin): ) # find which key is mine for x_pubkey in x_pubkeys: - xpub, s = BIP32_Account.parse_xpubkey(x_pubkey) - if xpub in self.xpub_path: - xpub_n = self.get_client().expand_path(self.xpub_path[xpub]) - txinputtype.address_n.extend(xpub_n + s) - break - else: - raise + if is_extended_pubkey(x_pubkey): + xpub, s = BIP32_Account.parse_xpubkey(x_pubkey) + if xpub in self.xpub_path: + xpub_n = self.get_client().expand_path(self.xpub_path[xpub]) + txinputtype.address_n.extend(xpub_n + s) + break + else: + raise prev_hash = unhexlify(txin['prevout_hash']) prev_index = txin['prevout_n'] diff --git a/plugins/trezor.py b/plugins/trezor.py index ad46679c..259237cb 100644 --- a/plugins/trezor.py +++ b/plugins/trezor.py @@ -282,13 +282,14 @@ class Plugin(BasePlugin): ) # find which key is mine for x_pubkey in x_pubkeys: - xpub, s = BIP32_Account.parse_xpubkey(x_pubkey) - if xpub in self.xpub_path: - xpub_n = self.get_client().expand_path(self.xpub_path[xpub]) - txinputtype.address_n.extend(xpub_n + s) - break - else: - raise + if is_extended_pubkey(x_pubkey): + xpub, s = BIP32_Account.parse_xpubkey(x_pubkey) + if xpub in self.xpub_path: + xpub_n = self.get_client().expand_path(self.xpub_path[xpub]) + txinputtype.address_n.extend(xpub_n + s) + break + else: + raise prev_hash = unhexlify(txin['prevout_hash']) prev_index = txin['prevout_n']