fix: handle missing bolt11 in CLN list_payments for keysend/BOLT12#307
Merged
Merged
Conversation
Follow-up to fusion44#290 — same class of bug, different code path. list_payments() in cln_jrpc.py unconditionally indexed p["bolt11"] for any incomplete payment, causing a KeyError -> the function returned None and then list_all_tx() crashed with `TypeError: 'NoneType' object is not iterable`, returning HTTP 500 to the Transactions view. CLN's `listpays` does not include `bolt11` for keysend payments or for BOLT12 offer payments, so any node that has ever made one of those will hit this on every Transactions load. Fix: guard the bolt11 decode the same way fusion44#290 guards invoice fields — only decode when bolt11 is present, and fall back to amount_sent_msat when neither bolt11 nor amount_msat are available, so the payment still shows up in the list. Reproduced on RaspiBlitz v1.12.1 with Core Lightning v25.12.1 and a keysend payment in history.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #290 — same class of bug, different code path.
list_payments()inapp/lightning/impl/cln_jrpc.pyunconditionally indexedp["bolt11"]for any incomplete payment:CLN's
listpaysdoes not includebolt11for keysend payments or BOLT12 offer payments, so any node that has ever made one of those hits aKeyError: 'bolt11'. Becauselist_paymentsis decorated with@logger.catch, the exception is swallowed and the function returnsNone. Its callerlist_all_tx()then crashes withTypeError: 'NoneType' object is not iterable, and the/lightning/list-all-txendpoint returns HTTP 500 — breaking the Transactions view in the web UI on every load.Fix
Guard the bolt11 decode the same way #290 guards invoice fields:
_decode_bolt11_cachedwhenbolt11is actually present.bolt11is missing andamount_msatis missing, fall back toamount_sent_msat(or0) soPayment.from_cln_jrpcstill sees the field it expects and the payment still shows up in the list.amount_msatis already populated by CLN (the common case for keysend), skip the decode entirely.Reproduction
journalctl -u blitzapi:After the patch,
list_paymentsreturns the full list including keysend/BOLT12 entries, and the Transactions view loads.Notes
Payment.from_cln_jrpcfor other potentially-missing CLN fields could be done separately; this PR keeps the scope to the actual observed crash.