diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index dc9beddc1..9d061dd97 100644 --- a/electrum/address_synchronizer.py +++ b/electrum/address_synchronizer.py @@ -208,12 +208,13 @@ class AddressSynchronizer(Logger, EventListener): self.verifier = SPV(self.network, self) self.asyncio_loop = network.asyncio_loop self.register_callbacks() + self._update_stored_local_height() @event_listener @with_lock def on_event_blockchain_updated(self, *args): self.invalidate_cache() - self.db.put('stored_height', self.get_local_height()) + self._update_stored_local_height() async def stop(self): if self.network: @@ -694,6 +695,9 @@ class AddressSynchronizer(Logger, EventListener): return cached_local_height return self.network.get_local_height() if self.network else self.db.get('stored_height', 0) + def _update_stored_local_height(self) -> None: + self.db.put('stored_height', self.get_local_height()) + def set_future_tx(self, txid: str, *, wanted_height: int): """Mark a local tx as "future" (encumbered by a timelock). wanted_height is the min (abs) block height at which the tx can get into the mempool (be broadcast).