electrum

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

commit 93c7aee2c8de64e85990f6f93bc79b5409205d22
parent e9340db4091a50266fb69cc14a91acbefd943ed1
Author: thomasv <thomasv@gitorious>
Date:   Wed, 11 Sep 2013 17:42:32 +0200

cleanup: next_addresses

Diffstat:
Mlib/wallet.py | 22++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/lib/wallet.py b/lib/wallet.py @@ -157,7 +157,7 @@ class Wallet: self.master_public_keys = storage.get('master_public_keys',{}) self.master_private_keys = storage.get('master_private_keys', {}) - self.first_addresses = storage.get('first_addresses',{}) + self.next_addresses = storage.get('next_addresses',{}) if self.seed_version < 4: raise ValueError("This wallet seed is deprecated.") @@ -351,12 +351,12 @@ class Wallet: i = self.num_accounts(account_type) k = self.account_id(account_type,i) - addr = self.first_addresses.get(k) + addr = self.next_addresses.get(k) if not addr: account_id, account = self.next_account(account_type) addr = account.first_address() - self.first_addresses[k] = addr - self.storage.put('first_addresses',self.first_addresses) + self.next_addresses[k] = addr + self.storage.put('next_addresses',self.next_addresses) return addr @@ -431,14 +431,15 @@ class Wallet: self.accounts[k] = BIP32_Account(v) - def addresses(self, include_change = True): + def addresses(self, include_change = True, next=False): o = self.get_account_addresses(-1, include_change) for a in self.accounts.keys(): o += self.get_account_addresses(a, include_change) - for addr in self.first_addresses.values(): - if addr not in o: - o += [addr] + if next: + for addr in self.next_addresses.values(): + if addr not in o: + o += [addr] return o @@ -475,9 +476,6 @@ class Wallet: if address in self.imported_keys.keys(): return -1, None - if address in self.first_addresses.values(): - return -1, None - for account in self.accounts.keys(): for for_change in [0,1]: addresses = self.accounts[account].get_addresses(for_change) @@ -1425,7 +1423,7 @@ class WalletSynchronizer(threading.Thread): time.sleep(1) # subscriptions - self.subscribe_to_addresses(self.wallet.addresses(True)) + self.subscribe_to_addresses(self.wallet.addresses(True, next=True)) while self.is_running(): # 1. create new addresses