commit 60cefeafcaddf64711c51f0cbc96db0d51f33e94
parent 27b8b21f9ea76babba3e012f8fdd017048c59515
Author: thomasv <thomasv@gitorious>
Date: Sun, 3 Mar 2013 10:43:08 +0100
method get_private_keys for sequence
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
@@ -483,6 +483,10 @@ class DeterministicSequence:
secexp = self.stretch_key(seed)
return self.get_private_key_from_stretched_exponent(sequence, secexp)
+ def get_private_keys(self, sequence_list, seed):
+ secexp = self.stretch_key(seed)
+ return [ self.get_private_key_from_stretched_exponent( sequence, secexp) for sequence in sequence_list]
+
def check_seed(self, seed):
curve = SECP256k1
secexp = self.stretch_key(seed)
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -244,15 +244,20 @@ class Wallet:
def get_private_keys(self, addresses, password):
# decode seed in any case, in order to test the password
seed = self.decode_seed(password)
- secexp = self.sequences[0].stretch_key(seed)
out = {}
+ l_sequences = []
+ l_addresses = []
for address in addresses:
if address in self.imported_keys.keys():
out[address] = pw_decode( self.imported_keys[address], password )
else:
account, sequence = self.get_address_index(address)
if account == 0:
- out[address] = self.sequences[0].get_private_key_from_stretched_exponent( sequence, secexp)
+ l_sequences.append(sequence)
+ l_addresses.append(address)
+
+ pk = self.sequences[0].get_private_keys(l_sequences, seed)
+ for i, address in enumerate(l_addresses): out[address] = pk[i]
return out