Browse Source

wallet: address_is_old minor clean-up

also, synchronize was defined twice in AddressSynchronizer
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 5 years ago
parent
commit
d1dea9343e
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/address_synchronizer.py
  2. 14
      electrum/wallet.py

3
electrum/address_synchronizer.py

@ -96,9 +96,6 @@ class AddressSynchronizer(Logger):
self.load_unverified_transactions() self.load_unverified_transactions()
self.remove_local_transactions_we_dont_have() self.remove_local_transactions_we_dont_have()
def synchronize(self):
pass
def is_mine(self, address) -> bool: def is_mine(self, address) -> bool:
return self.db.is_addr_in_history(address) return self.db.is_addr_in_history(address)

14
electrum/wallet.py

@ -973,17 +973,20 @@ class Abstract_Wallet(AddressSynchronizer):
def can_export(self): def can_export(self):
return not self.is_watching_only() and hasattr(self.keystore, 'get_private_key') return not self.is_watching_only() and hasattr(self.keystore, 'get_private_key')
def address_is_old(self, address, age_limit=2): def address_is_old(self, address: str, *, req_conf: int = 3) -> bool:
age = -1 """Returns whether address has any history that is deeply confirmed.
Note: this is NOT verified using SPV. (TODO should it be?)
"""
max_conf = -1
h = self.db.get_addr_history(address) h = self.db.get_addr_history(address)
for tx_hash, tx_height in h: for tx_hash, tx_height in h:
if tx_height <= 0: if tx_height <= 0:
tx_age = 0 tx_age = 0
else: else:
tx_age = self.get_local_height() - tx_height + 1 tx_age = self.get_local_height() - tx_height + 1
if tx_age > age: max_conf = max(max_conf, tx_age)
age = tx_age return max_conf >= req_conf
return age > age_limit
def bump_fee(self, *, tx, new_fee_rate, config) -> Transaction: def bump_fee(self, *, tx, new_fee_rate, config) -> Transaction:
"""Increase the miner fee of 'tx'. """Increase the miner fee of 'tx'.
@ -1889,6 +1892,7 @@ class Deterministic_Wallet(Abstract_Wallet):
else: else:
break break
@AddressSynchronizer.with_local_height_cached
def synchronize(self): def synchronize(self):
with self.lock: with self.lock:
self.synchronize_sequence(False) self.synchronize_sequence(False)

Loading…
Cancel
Save