Browse Source

create a PendingAccount if coins have been sent to next_account

283
ThomasV 10 years ago
parent
commit
374daa25af
  1. 2
      gui/qt/main_window.py
  2. 17
      lib/wallet.py
  3. 2
      plugins/trezor.py

2
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:

17
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()

2
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)

Loading…
Cancel
Save