AddressSynchronizer: invalidate balance cache on spv
What changed, and why it matters
This commit fixes a display-only bug in Electrum where, under certain timing conditions, a transaction that already had one blockchain confirmation could briefly be shown as 'unconfirmed' in the wallet balance. The fix adds a cache refresh right after a transaction is SPV-verified, so the balance is recalculated with the correct confirmation count. It does not allow theft, transaction manipulation, or remote code execution.
Treat as a routine bug fix. No urgent security response is required. Users and integrators should update to the patched version to avoid confusing balance displays, especially on QML builds.
Security signals we found
UI/balance display inconsistency caused by stale cache
Race condition between balance cache invalidation and SPV verification
No cryptographic, network, or authorization boundary crossed
Evidence from the diff
AddressSynchronizer caches wallet balances. The cache was invalidated on blockchain update and on receiving history, but if get_balance() was called before the transaction completed SPV verification, the cache was populated using height=0 (unconfirmed). Once SPV verification later set the real height, the stale unconfirmed cache entry persisted until another invalidation event. The patch calls self.invalidate_cache() inside add_verified_tx() after the verified transaction is stored, forcing a recalculation with the verified height.
Changed components
electrum/address_synchronizer.pyAddressSynchronizer balance cacheSPV verification flowInspect captured patch +1 / −0
diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py
index 0197ba0..dc9bedd 100644
--- a/electrum/address_synchronizer.py
+++ b/electrum/address_synchronizer.py
@@ -652,6 +652,7 @@ class AddressSynchronizer(Logger, EventListener):
with self.lock:
self.unverified_tx.pop(tx_hash, None)
self.db.add_verified_tx(tx_hash, info)
+ self.invalidate_cache()
util.trigger_callback('adb_added_verified_tx', self, tx_hash)
@with_lock
Why this scored 24/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.