qml: qetransactionlistmodel mark self dirty on tx events
What changed, and why it matters
This commit fixes a user-interface bug in Electrum's mobile/QML wallet view. Previously, address-specific transaction lists were not refreshed when transactions arrived, were removed, or changed confirmation status, so stale or missing entries could remain on screen. The fix moves the refresh logic into the transaction list model itself so all such lists update correctly. There is no indication this is a security vulnerability.
No security action required. Treat as a normal UI correctness fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch moves transaction-event dirty-marking and model refresh from QEWallet into QETransactionListModel. New handlers in the model listen for new_transaction, removed_transaction, adb_tx_height_changed, and wallet_updated. This ensures per-address history models (e.g., QEAddressDetails) are refreshed, not just the main wallet history model. The qewallet.py side removes the corresponding historyModel.setDirty()/initModel() calls. Lightning history still requires marking dirty on every wallet_updated because lightning changes do not emit transaction events.
Changed components
electrum/gui/qml/qetransactionlistmodel.pyelectrum/gui/qml/qewallet.pyInspect captured patch +24 / −11
### electrum/gui/qml/qetransactionlistmodel.py
@@ -87,6 +87,30 @@ def on_event_labels_received(self, wallet, labels):
if wallet == self.wallet:
self.initModel(True) # TODO: be less dramatic
+ @qt_event_listener
+ def on_event_new_transaction(self, wallet, tx):
+ if wallet == self.wallet:
+ self.setDirty() # assuming wallet.is_up_to_date triggers after
+
+ @qt_event_listener
+ def on_event_removed_transaction(self, wallet, tx):
+ if wallet == self.wallet:
+ self.setDirty()
+
+ @qt_event_listener
+ def on_event_adb_tx_height_changed(self, adb, txid, old_height, new_height):
+ if adb == self.wallet.adb:
+ self._logger.debug(f'tx_height_changed {txid}. {old_height} -> {new_height}')
+ self.setDirty() # assuming wallet.is_up_to_date triggers after
+
+ @qt_event_listener
+ def on_event_wallet_updated(self, wallet):
+ if wallet == self.wallet:
+ if self.include_lightning:
+ self.setDirty() # lightning history changes don't come with tx events, see #9856
+ if wallet.is_up_to_date():
+ self.initModel() # refresh if dirty
+
def rowCount(self, index):
return len(self.tx_history)
### electrum/gui/qml/qewallet.py
@@ -206,36 +206,25 @@ def on_event_new_transaction(self, wallet: 'Abstract_Wallet', tx: Transaction):
if wallet == self.wallet:
self._logger.debug(f'new transaction {tx.txid()}')
self.add_tx_notification(tx)
- self.historyModel.setDirty() # assuming wallet.is_up_to_date triggers after
if self.wallet.is_up_to_date():
# don't update during sync as this recomputes the balance on each new tx, blocking the UI thread.
# on_event_wallet_updated emits balanceChanged once we are up-to-date.
self.balanceChanged.emit()
- @qt_event_listener
- def on_event_adb_tx_height_changed(self, adb, txid, old_height, new_height):
- if adb == self.wallet.adb:
- self._logger.debug(f'tx_height_changed {txid}. {old_height} -> {new_height}')
- self.historyModel.setDirty() # assuming wallet.is_up_to_date triggers after
-
@qt_event_listener
def on_event_removed_transaction(self, wallet, tx):
# NOTE: this event only triggers once, only for the first deleted tx, when for imported wallets an address
# is deleted along with multiple associated txs
if wallet == self.wallet:
self._logger.info(f'removed transaction {tx.txid()}')
- self.historyModel.setDirty()
self.balanceChanged.emit()
@qt_event_listener
def on_event_wallet_updated(self, wallet):
if wallet == self.wallet:
self._logger.debug('wallet_updated')
self.balanceChanged.emit()
- self.historyModel.setDirty()
self.synchronizing = not wallet.is_up_to_date()
- if not self.synchronizing:
- self.historyModel.initModel() # refresh if dirty
@event_listener
def on_event_channel(self, wallet, channel):Why this scored 18/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.