qml: qetransactionlistmodel: refresh on payment_succeeded, request_status callbacks
What changed, and why it matters
This commit is a UI refresh fix for the Electrum mobile/QML wallet. It moves responsibility for updating the transaction history list from one wallet component to the transaction list model itself, and adds refresh triggers when a Lightning payment succeeds or a payment request is paid. It also fixes a minor typo where the wrong wallet variable was used when checking whether an address can be deleted. There is no direct security vulnerability here; it is a correctness and consistency improvement for the user interface.
No security action required. Treat as a normal UI correctness patch. Reviewers may optionally verify that the history model refreshes correctly after Lightning payments and address deletion in the QML build.
Security signals we found
UI state synchronization fix
Lightning payment history refresh
Minor variable reference bugfix in address deletion UI
Evidence from the diff
The patch refactors event handling in the QML GUI layer. Previously, qewallet.py called self.historyModel.initModel(True) inside on_event_request_status and on_event_payment_succeeded. These calls are removed and replaced with equivalent listeners inside qetransactionlistmodel.py, scoped to the correct wallet and to lightning-inclusive models. A comment in qeaddressdetails.py explains why setDirty() is called explicitly after delete_address, because delete_address may not trigger adb_removed_tx when the removed address shares a transaction with another imported address. The same file also fixes a bug where self.wallet.wallet.can_delete_address() was used instead of self._wallet.wallet.can_delete_address().
Changed components
electrum/gui/qml/qetransactionlistmodel.pyelectrum/gui/qml/qewallet.pyelectrum/gui/qml/qeaddressdetails.pyInspect captured patch +18 / −8
### electrum/gui/qml/qeaddressdetails.py
@@ -143,6 +143,8 @@ def deleteAddress(self):
assert self.canDelete
try:
self._wallet.wallet.delete_address(self._address)
+ # explicit mark-dirty, as delete_address is not guaranteed to trigger adb_removed_tx callback.
+ # (e.g. when the removed address shares a tx with another imported address)
self._wallet.historyModel.setDirty()
except UserFacingException as e:
self.addressDeleteFailed.emit(str(e))
@@ -166,5 +168,5 @@ def update(self):
if self._wallet.derivationPrefix:
self._derivationPath = self._derivationPath.replace('m', self._wallet.derivationPrefix)
self._numtx = self._wallet.wallet.adb.get_address_history_len(self._address)
- self._candelete = self.wallet.wallet.can_delete_address()
+ self._candelete = self._wallet.wallet.can_delete_address()
self.detailsChanged.emit()
### electrum/gui/qml/qetransactionlistmodel.py
@@ -7,6 +7,7 @@
from electrum.logging import get_logger
from electrum.util import Satoshis, TxMinedInfo
from electrum.address_synchronizer import TX_HEIGHT_FUTURE, TX_HEIGHT_LOCAL
+from electrum.invoices import PR_PAID
from electrum.gui.common_qt.util import QtEventListener, qt_event_listener
@@ -111,6 +112,20 @@ def on_event_wallet_updated(self, wallet):
if wallet.is_up_to_date():
self.initModel() # refresh if dirty
+ @qt_event_listener
+ def on_event_payment_succeeded(self, wallet, key):
+ # only on include_lightning, as the payment_succeeded callback is lightning only
+ if wallet == self.wallet and self.include_lightning:
+ # TODO: we can probably just add the payment instead of recreating the whole history (expensive)
+ self.initModel(True)
+
+ @qt_event_listener
+ def on_event_request_status(self, wallet, key, status):
+ # only on include_lightning, as the new_transaction callback already handles on-chain
+ if wallet == self.wallet and status == PR_PAID and self.include_lightning:
+ # TODO: we can probably just add the payment instead of recreating the whole history (expensive)
+ self.initModel(True)
+
def rowCount(self, index):
return len(self.tx_history)
### electrum/gui/qml/qewallet.py
@@ -188,12 +188,6 @@ def on_event_request_status(self, wallet, key, status):
if wallet == self.wallet:
self._logger.debug('request status %d for key %s' % (status, key))
self.requestStatusChanged.emit(key, status)
- if status == PR_PAID:
- # might be new incoming LN payment, update history
- # TODO: only update if it was paid over lightning,
- # and even then, we can probably just add the payment instead
- # of recreating the whole history (expensive)
- self.historyModel.initModel(True)
@event_listener
def on_event_invoice_status(self, wallet, key, status):
@@ -242,7 +236,6 @@ def on_event_channels_updated(self, wallet):
def on_event_payment_succeeded(self, wallet, key):
if wallet == self.wallet:
self.paymentSucceeded.emit(key)
- self.historyModel.initModel(True) # TODO: be less dramatic
@event_listener
def on_event_payment_failed(self, wallet, key, reason):Why this scored 17/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.