From 72f083d2d00b0bdf65348d45b7ccdb5d8092419c Mon Sep 17 00:00:00 2001 From: f321x Date: Wed, 7 Jan 2026 16:24:50 +0100 Subject: [PATCH 1/2] AddressSynchronizer: remove unneccessary loop This loop seems like a leftover that is not useful anymore, clearing the cache once has the same effect. --- electrum/address_synchronizer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index a946426e8..0197ba032 100644 --- a/electrum/address_synchronizer.py +++ b/electrum/address_synchronizer.py @@ -413,8 +413,7 @@ class AddressSynchronizer(Logger, EventListener): tx = self.db.remove_transaction(tx_hash) remove_from_spent_outpoints() self._remove_tx_from_local_history(tx_hash) - for addr in itertools.chain(self.db.get_txi_addresses(tx_hash), self.db.get_txo_addresses(tx_hash)): - self.invalidate_cache() + self.invalidate_cache() self.db.remove_txi(tx_hash) self.db.remove_txo(tx_hash) self.db.remove_tx_fee(tx_hash) From 663fcddc0c0e95d66b264e52d46fd936ce9d7f25 Mon Sep 17 00:00:00 2001 From: f321x Date: Wed, 7 Jan 2026 18:15:08 +0100 Subject: [PATCH 2/2] AddressSynchronizer: invalidate balance cache on spv There was a race incorrectly counting transactions with one confirmations to the unconfirmed balance instead of the confirmed balance. This happened because the balance cache of AddressSynchronizer got invalidated after `on_event_blockchain_updated` and then again after `receive_history_callback`->`add_transaction`, however when calling `AddressSynchronizer.get_balance()` before the tx got spv verified the height would still be counted as 0 (unconfirmed), populating the balance cache again with the unconfirmed balance. I noticed this only on QML due to timing differences to Qt. Invalidating the cache in `AddressSynchronizer.add_verified_tx()` after the tx got verified causes the balance to get recalculated and shown correctly. --- electrum/address_synchronizer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index 0197ba032..dc9beddc1 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