From 553493364e5241463b1582a716c772456a307a39 Mon Sep 17 00:00:00 2001 From: thomasv Date: Sun, 4 Aug 2013 16:46:47 +0200 Subject: [PATCH] get_new_address -> get_address --- lib/account.py | 17 ++++++----------- lib/wallet.py | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/account.py b/lib/account.py index b734d1447..85a3471f3 100644 --- a/lib/account.py +++ b/lib/account.py @@ -35,12 +35,12 @@ class Account(object): def create_new_address(self, for_change): addresses = self.change if for_change else self.addresses n = len(addresses) - address = self.get_new_address( for_change, n) + address = self.get_address( for_change, n) addresses.append(address) print address return address - def get_new_address(self, for_change, n): + def get_address(self, for_change, n): pass @@ -156,7 +156,7 @@ class BIP32_Account(Account): d['cK'] = self.cK.encode('hex') return d - def get_new_address(self, for_change, n): + def get_address(self, for_change, n): pubkey = self.get_pubkey(for_change, n) address = public_key_to_bc_address( pubkey ) return address @@ -168,12 +168,6 @@ class BIP32_Account(Account): K, K_compressed, chain = CKD_prime(K, chain, i) return K_compressed - def get_address(self, sequence): - for_change, n = sequence - pubkey = self.get_pubkey(for_change, n) - address = public_key_to_bc_address( pubkey ) - return address - def get_private_key(self, sequence, master_k): chain = self.c k = master_k @@ -189,7 +183,8 @@ class BIP32_Account(Account): assert self.mpk == (master_public_key.encode('hex'), master_chain.encode('hex')) def get_input_info(self, sequence): - pk_addr = self.get_address(sequence) + chain, i = sequence + pk_addr = self.get_address(chain, i) redeemScript = None return pk_addr, redeemScript @@ -217,7 +212,7 @@ class BIP32_Account_2of2(BIP32_Account): K, K_compressed, chain = CKD_prime(K, chain, i) return K_compressed - def get_new_address(self, for_change, n): + def get_address(self, for_change, n): pubkey1 = self.get_pubkey(for_change, n) pubkey2 = self.get_pubkey2(for_change, n) address = Transaction.multisig_script([pubkey1.encode('hex'), pubkey2.encode('hex')], 2)["address"] diff --git a/lib/wallet.py b/lib/wallet.py index 0bc757ee4..d5da6b31a 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -313,10 +313,10 @@ class Wallet: pk = self.accounts["m/0'/0'"].get_private_key(sequence, master_k) out[address] = pk - elif account == "m/1'/1 & m/2'/1": + elif account == "m/1'/0 & m/2'/0": master_k = self.master_private_keys["m/1'/"] master_c, master_K, _ = self.master_public_keys["m/1'/"] - master_k, master_c = CKD(master_k.decode('hex'), master_c.decode('hex'), 1) + master_k, master_c = CKD(master_k.decode('hex'), master_c.decode('hex'), 0) pk = self.accounts[account].get_private_key(sequence, master_k) out[address] = pk