electrum

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

commit 374daa25afd06237b07a6b1abed2c8fcc648e22b
parent 501bbdbd6799b0c86c02f7605c8c04e42b7382ac
Author: ThomasV <thomasv@gitorious>
Date:   Wed, 10 Sep 2014 10:09:13 +0200

create a PendingAccount if coins have been sent to next_account

Diffstat:
Mgui/qt/main_window.py | 2+-
Mlib/wallet.py | 17+++++++++++++++++
Mplugins/trezor.py | 2+-
3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -2281,7 +2281,7 @@ class ElectrumWindow(QMainWindow): vbox.addLayout(h) private_keys = {} - addresses = self.wallet.addresses(True, False) + addresses = self.wallet.addresses(True) done = False def privkeys_thread(): for addr in addresses: diff --git a/lib/wallet.py b/lib/wallet.py @@ -1343,6 +1343,13 @@ class BIP32_HD_Wallet(BIP32_Wallet): l.append(next_address) return l + def get_address_index(self, address): + if self.next_account: + next_id, next_xpub, next_address = self.next_account + if address == next_address: + return next_id, (0,0) + return BIP32_Wallet.get_address_index(self, address) + def num_accounts(self): keys = [] for k, v in self.accounts.items(): @@ -1390,6 +1397,9 @@ class BIP32_HD_Wallet(BIP32_Wallet): assert type(self.accounts.get(k)) == PendingAccount self.accounts.pop(k) self.save_accounts() + # prepare the next account + self.next_account = self.get_next_account(password) + self.storage.put('next_account', self.next_account) def create_pending_account(self, name, password): next_id, next_xpub, next_address = self.next_account if self.next_account else self.get_next_account_address(password) @@ -1407,6 +1417,7 @@ class BIP32_HD_Wallet(BIP32_Wallet): if self.next_account is None: try: self.next_account = self.get_next_account(None) + self.storage.put('next_account', self.next_account) except: pass @@ -1418,6 +1429,12 @@ class BIP32_HD_Wallet(BIP32_Wallet): self.add_account(next_id, BIP32_Account({'xpub':next_xpub})) # here the user should get a notification self.next_account = None + self.storage.put('next_account', self.next_account) + elif self.history.get(next_address, []): + if next_id not in self.accounts: + print_error("create pending account", next_id) + self.accounts[next_id] = PendingAccount({'pending':next_address}) + self.save_accounts() diff --git a/plugins/trezor.py b/plugins/trezor.py @@ -351,7 +351,7 @@ class TrezorWallet(NewWallet): def check_proper_device(self): self.get_client().ping('t') if not self.device_checked: - address = self.addresses(False, False)[0] + address = self.addresses(False)[0] address_id = self.address_id(address) n = self.get_client().expand_path(address_id) device_address = self.get_client().get_address('Bitcoin', n)