Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions electrum/gui/qml/qelnpaymentdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,20 @@ def update(self):
self._logger.error('wallet undefined')
return

# TODO this is horribly inefficient. need a payment getter/query method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete this comment?

tx = self._wallet.wallet.lnworker.get_lightning_history()[self._key]
self._logger.debug(str(tx))
history = self._wallet.wallet.lnworker.get_lightning_history()
tx = history.get(self._key)
if tx is None:
self._logger.warning(f"Payment key {self._key} not found in history.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can it happen that the key is missing?
How do you enter the this dialog? Is it directly after making a payment, or clicking an item in the history list? (those are the two entry points)

Copy link
Author

@harsh1504660 harsh1504660 Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SomberNight this is what I am thinking,

  • lnworker.get_lightning_history() is populated asynchronously (callbacks from lnwatcher/lntransport etc).

  • The UI can request to show details in two main ways:

  • Right after a payment event (e.g. send flow opens details / or notification allows “show details”), and

  • From a user clicking a history item in the GUI list.

  • If the GUI constructs the dialog with a key (payment hash) and the lnworker hasn’t yet inserted that key into the history, a dict[key] lookup raises KeyError.

  • Similarly, if the history was refreshed such that the item was removed (cleanup, expiry, or replacement), the GUI may have a stale key when the user clicks.

return # Or set fields to empty/default

self._fee.msatsInt = 0 if not tx.fee_msat else int(tx.fee_msat)
self._amount.msatsInt = int(tx.amount_msat)
self._label = tx.label
self._date = format_time(tx.timestamp)
self._timestamp = tx.timestamp
self._status = 'settled' # TODO: other states? get_lightning_history is deciding the filter for us :(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete this comment? seems unrelated

self._status = 'settled'
self._phash = tx.payment_hash
self._preimage = tx.preimage

self.detailsChanged.emit()