electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 08543584c523c382ff37454598426aa446a940a9
parent a132525a2b73f6f23b2fe6d4105aead6b23c7ad1
Author: ThomasV <thomasv@electrum.org>
Date:   Wed, 21 Sep 2016 16:23:24 +0200

fix cold storage signing for imported wallets

Diffstat:
Mlib/keystore.py | 11+++++++----
Mlib/wallet.py | 13++++++++++++-
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lib/keystore.py b/lib/keystore.py @@ -173,11 +173,14 @@ class Imported_KeyStore(Software_KeyStore): raise InvalidPassword() return pk - def get_pubkey_derivation(self, pubkey): - if pubkey not in self.receiving_keys: + def get_pubkey_derivation(self, x_pubkey): + if x_pubkey[0:2] != 'fd': return - i = self.receiving_keys.index(pubkey) - return (False, i) + # fixme: this assumes p2pkh + _, addr = xpubkey_to_address(x_pubkey) + for i, pubkey in enumerate(self.receiving_pubkeys): + if public_key_to_bc_address(pubkey.decode('hex')) == addr: + return (False, i) def update_password(self, old_password, new_password): if old_password is not None: diff --git a/lib/wallet.py b/lib/wallet.py @@ -1175,6 +1175,11 @@ class Imported_Wallet(Abstract_Wallet): def load_addresses(self): self.addresses = self.storage.get('addresses', []) + self.receiving_addresses = self.addresses + self.change_addresses = [] + + def get_keystores(self): + return [] def has_password(self): return False @@ -1231,6 +1236,12 @@ class Imported_Wallet(Abstract_Wallet): def get_change_addresses(self): return [] + def add_input_sig_info(self, txin, address): + addrtype, hash160 = bc_address_to_hash_160(address) + xpubkey = 'fd' + (chr(addrtype) + hash160).encode('hex') + txin['x_pubkeys'] = [ xpubkey ] + txin['pubkeys'] = [ xpubkey ] + txin['signatures'] = [None] class P2PK_Wallet(Abstract_Wallet): @@ -1518,7 +1529,7 @@ class Multisig_Wallet(Deterministic_Wallet): pubkeys = self.get_pubkeys(*derivation) x_pubkeys = [k.get_xpubkey(*derivation) for k in self.get_keystores()] # sort pubkeys and x_pubkeys, using the order of pubkeys - pubkeys, x_pubkeys = zip( *sorted(zip(pubkeys, x_pubkeys))) + pubkeys, x_pubkeys = zip(*sorted(zip(pubkeys, x_pubkeys))) txin['pubkeys'] = list(pubkeys) txin['x_pubkeys'] = list(x_pubkeys) txin['signatures'] = [None] * len(pubkeys)