Skip to content

Conversation

harsh1504660
Copy link

@harsh1504660 harsh1504660 commented Aug 9, 2025

Prevents crash when Lightning payment key is missing in QELnPaymentDetails.update by using dict.get() and logging a warning instead of raising a KeyError

Issue #10116

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.

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?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants