Skip to content

lnpeer/lnutil: fail mpp if we didn't signal mpp in invoice#10351

Merged
SomberNight merged 6 commits intospesmilo:masterfrom
f321x:jit_htlc_switch_fixes
Dec 10, 2025
Merged

lnpeer/lnutil: fail mpp if we didn't signal mpp in invoice#10351
SomberNight merged 6 commits intospesmilo:masterfrom
f321x:jit_htlc_switch_fixes

Conversation

@f321x
Copy link
Copy Markdown
Member

@f321x f321x commented Dec 8, 2025

Followup of #10348
Fails incoming htlcs if we requested a single part payment by disabling the mpp flag in the invoice features but the sender sent us multiple htlcs anyways. This is done by storing the invoice features in the PaymentInfo class and checking against them when receiving the htlcs.

Also changes the channel reference in ReceivedMPPHtlc from scid to the full channel_id to simplify it and prevent issues with just in time channels where the scid can be None as the channel is used before a funding tx has been mined. (Alternatively we could use the local scid alias, but that seems more error prone).

Comment thread electrum/lnpeer.py Outdated
Comment on lines +3080 to +3082
if jit_opening_fees_msat and len(mpp_set.htlcs) > 1:
# we don't support mpp with just-in-time channel openings, the payer has to send a single htlc
return OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, None, None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally we should know whether the invoice we created signalled MPP, and just check against that.
That would work if e.g. invoice_features were part of payment_info. In that case the check could even be done on the individual htlc in _check_unfulfilled_htlc.
but ok, not sure if we want to do that now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doing that now in 0ce2fa8.
It seems cleaner and more generic.
The persisted features could get stale if the user changes the config (e.g. from gossip to trampoline), then shows the invoice again and tries to pay it, though i guess thats acceptable

Comment thread electrum/lnutil.py Outdated
f321x added 2 commits December 9, 2025 14:44
Prevents accidentally passing None if channel.short_id is not set yet
Store the channel id instead of the scid in ReceivedMPPHtlc.
The scid can be None, in theory even for multiple channels at the same
time. Using the channel_id which is always available and unique seems
less error prone at the cost of temporarily higher storage requirements
in the db for the duration of the pending htlcs.

Alternatively we could use the local scid alias however using the
channel_id seems less complex and leaves less room for ambiguity.
@f321x f321x force-pushed the jit_htlc_switch_fixes branch from c50589f to 5421fa6 Compare December 9, 2025 16:51
Adds the invoice features to the `PaymentInfo` class so we can check if
the sender respects our requested features (e.g. if they tried to send
mpp if we requested no mpp).
Fail incoming htlcs if we receive a payment consisting of multiple parts
if we signaled to not want mpp in the invoice.
@f321x f321x force-pushed the jit_htlc_switch_fixes branch from 5421fa6 to 7c01d9d Compare December 10, 2025 09:36
@f321x f321x changed the title lnpeer/lnutil: fail htlcs if just in time payment gets mpp lnpeer/lnutil: fail mpp if we didn't signal mpp in invoice Dec 10, 2025
Copy link
Copy Markdown
Member

@SomberNight SomberNight left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

@SomberNight SomberNight merged commit 6ceb4ad into spesmilo:master Dec 10, 2025
1 of 16 checks passed
@f321x f321x deleted the jit_htlc_switch_fixes branch December 10, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants