-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(gui): avoid KeyError in QELnPaymentDetails.update when key missing issue:#10116 #10118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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.") |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 :( |
There was a problem hiding this comment.
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
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