|
@ -1139,25 +1139,23 @@ class Deterministic_Wallet(Abstract_Wallet): |
|
|
if n > nmax: nmax = n |
|
|
if n > nmax: nmax = n |
|
|
return nmax + 1 |
|
|
return nmax + 1 |
|
|
|
|
|
|
|
|
|
|
|
def create_new_address(self, account, for_change): |
|
|
|
|
|
address = account.create_new_address(for_change) |
|
|
|
|
|
self.history[address] = [] |
|
|
|
|
|
self.synchronizer.add(address) |
|
|
|
|
|
self.save_accounts() |
|
|
|
|
|
|
|
|
def synchronize_sequence(self, account, for_change): |
|
|
def synchronize_sequence(self, account, for_change): |
|
|
limit = self.gap_limit_for_change if for_change else self.gap_limit |
|
|
limit = self.gap_limit_for_change if for_change else self.gap_limit |
|
|
new_addresses = [] |
|
|
|
|
|
while True: |
|
|
while True: |
|
|
addresses = account.get_addresses(for_change) |
|
|
addresses = account.get_addresses(for_change) |
|
|
if len(addresses) < limit: |
|
|
if len(addresses) < limit: |
|
|
address = account.create_new_address(for_change) |
|
|
self.create_new_address(account, for_change) |
|
|
self.history[address] = [] |
|
|
|
|
|
new_addresses.append( address ) |
|
|
|
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
if map( lambda a: self.address_is_old(a), addresses[-limit:] ) == limit*[False]: |
|
|
if map( lambda a: self.address_is_old(a), addresses[-limit:] ) == limit*[False]: |
|
|
break |
|
|
break |
|
|
else: |
|
|
else: |
|
|
address = account.create_new_address(for_change) |
|
|
self.create_new_address(account, for_change) |
|
|
self.history[address] = [] |
|
|
|
|
|
new_addresses.append( address ) |
|
|
|
|
|
|
|
|
|
|
|
return new_addresses |
|
|
|
|
|
|
|
|
|
|
|
def check_pending_accounts(self): |
|
|
def check_pending_accounts(self): |
|
|
for account_id, addr in self.next_addresses.items(): |
|
|
for account_id, addr in self.next_addresses.items(): |
|
@ -1169,22 +1167,15 @@ class Deterministic_Wallet(Abstract_Wallet): |
|
|
self.next_addresses.pop(account_id) |
|
|
self.next_addresses.pop(account_id) |
|
|
|
|
|
|
|
|
def synchronize_account(self, account): |
|
|
def synchronize_account(self, account): |
|
|
new = [] |
|
|
self.synchronize_sequence(account, 0) |
|
|
new += self.synchronize_sequence(account, 0) |
|
|
self.synchronize_sequence(account, 1) |
|
|
new += self.synchronize_sequence(account, 1) |
|
|
|
|
|
return new |
|
|
|
|
|
|
|
|
|
|
|
def synchronize(self): |
|
|
def synchronize(self): |
|
|
self.check_pending_accounts() |
|
|
self.check_pending_accounts() |
|
|
new = [] |
|
|
|
|
|
for account in self.accounts.values(): |
|
|
for account in self.accounts.values(): |
|
|
if type(account) in [ImportedAccount, PendingAccount]: |
|
|
if type(account) in [ImportedAccount, PendingAccount]: |
|
|
continue |
|
|
continue |
|
|
new += self.synchronize_account(account) |
|
|
self.synchronize_account(account) |
|
|
if new: |
|
|
|
|
|
self.save_accounts() |
|
|
|
|
|
self.storage.put('addr_history', self.history, True) |
|
|
|
|
|
return new |
|
|
|
|
|
|
|
|
|
|
|
def restore(self, callback): |
|
|
def restore(self, callback): |
|
|
from i18n import _ |
|
|
from i18n import _ |
|
|