1
0

addr_sync: update "stored_height" db field immediately on wallet-open

Repro steps:
- in qt gui, with network enabled, open wallet1
- open wizard, create wallet2 (restore from seed something that has mined history)
- close both wallets, stop electrum
- start electrum with "-o" offline flag, open wallet2
- observe all txs in history tab show up as "unconfirmed"

The cause is that "stored_height" only gets updated ~on new blocks.
So if you created a wallet and closed it soon, its db would not contain "stored_height."
This commit is contained in:
SomberNight
2026-01-15 16:43:22 +00:00
parent 9857534e18
commit a27e2cc6b5

View File

@@ -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).