Browse Source

Merge pull request #3895 from SomberNight/fix_3890

locking in wallet.create_new_address
3.1
ThomasV 7 years ago
committed by GitHub
parent
commit
e0130cafcf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      lib/wallet.py

21
lib/wallet.py

@ -208,7 +208,7 @@ class Abstract_Wallet(PrintError):
self.up_to_date = False self.up_to_date = False
# locks: if you need to take multiple ones, acquire them in the order they are defined here! # locks: if you need to take multiple ones, acquire them in the order they are defined here!
self.lock = threading.Lock() self.lock = threading.RLock()
self.transaction_lock = threading.RLock() self.transaction_lock = threading.RLock()
self.check_history() self.check_history()
@ -1947,15 +1947,16 @@ class Deterministic_Wallet(Abstract_Wallet):
def create_new_address(self, for_change=False): def create_new_address(self, for_change=False):
assert type(for_change) is bool assert type(for_change) is bool
addr_list = self.change_addresses if for_change else self.receiving_addresses with self.lock:
n = len(addr_list) addr_list = self.change_addresses if for_change else self.receiving_addresses
x = self.derive_pubkeys(for_change, n) n = len(addr_list)
address = self.pubkeys_to_address(x) x = self.derive_pubkeys(for_change, n)
addr_list.append(address) address = self.pubkeys_to_address(x)
self._addr_to_addr_index[address] = (for_change, n) addr_list.append(address)
self.save_addresses() self._addr_to_addr_index[address] = (for_change, n)
self.add_address(address) self.save_addresses()
return address self.add_address(address)
return address
def synchronize_sequence(self, for_change): def synchronize_sequence(self, 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

Loading…
Cancel
Save