electrum

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

commit f68ecb3e26e25d0dcd5381357b30250373f4c9dc
parent f522d6c36dd06bddefc508ef6f8ef3198a8b96d7
Author: ThomasV <thomasv@gitorious>
Date:   Thu,  3 Apr 2014 14:15:02 +0200

multisig accounts: sort pubkeys

Diffstat:
Mlib/account.py | 24++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/lib/account.py b/lib/account.py @@ -147,8 +147,8 @@ class BIP32_Account(Account): def first_address(self): return self.get_address(0,0) - def get_pubkey(self, for_change, n): - _, _, _, c, cK = deserialize_xkey(self.xpub) + def get_pubkey(self, xpub, for_change, n): + _, _, _, c, cK = deserialize_xkey(xpub) for i in [for_change, n]: cK, c = CKD_pub(cK, c, i) return cK.encode('hex') @@ -157,7 +157,7 @@ class BIP32_Account(Account): return None def get_pubkeys(self, sequence): - return [self.get_pubkey(*sequence)] + return [self.get_pubkey(self.xpub, *sequence)] def get_master_pubkeys(self): return [self.xpub] @@ -181,14 +181,8 @@ class BIP32_Account_2of2(BIP32_Account): d['xpub2'] = self.xpub2 return d - def get_pubkey2(self, for_change, n): - _, _, _, c, cK = deserialize_xkey(self.xpub2) - for i in [for_change, n]: - cK, c = CKD_pub(cK, c, i) - return cK.encode('hex') - def redeem_script(self, sequence): - pubkeys = sorted(self.get_pubkeys(sequence)) + pubkeys = self.get_pubkeys(sequence) return Transaction.multisig_script(pubkeys, 2) def get_address(self, for_change, n): @@ -196,7 +190,7 @@ class BIP32_Account_2of2(BIP32_Account): return address def get_pubkeys(self, sequence): - return [ self.get_pubkey( *sequence ), self.get_pubkey2( *sequence )] + return sorted([ self.get_pubkey(self.xpub, *sequence ), self.get_pubkey(self.xpub2, *sequence )]) def get_master_pubkeys(self): return [self.xpub, self.xpub2] @@ -216,14 +210,8 @@ class BIP32_Account_2of3(BIP32_Account_2of2): d['xpub3'] = self.xpub3 return d - def get_pubkey3(self, for_change, n): - _, _, _, c, cK = deserialize_xkey(self.xpub3) - for i in [for_change, n]: - cK, c = CKD_pub(cK, c, i) - return cK.encode('hex') - def get_pubkeys(self, sequence): - return [ self.get_pubkey( *sequence ), self.get_pubkey2( *sequence ), self.get_pubkey3( *sequence )] + return sorted([ self.get_pubkey(self.xpub, *sequence ), self.get_pubkey(self.xpub2, *sequence ), self.get_pubkey(self.xpub3, *sequence )]) def get_master_pubkeys(self): return [self.xpub, self.xpub2, self.xpub3]