Skip to content

Conversation

@f321x
Copy link
Member

@f321x f321x commented Sep 3, 2025

Fixes some todos in LNPeer.maybe_fulfill_htlc().

  1. Enforces the min_final_cltv_delta requested in the lightning invoice for incoming htlcs that will not get directly settled, this is relevant for hold invoices.
  2. Enforces the invoice expiry, rejects incoming htlcs if the associated lightning invoice has already expired.
  3. Rejects incoming htlcs if the lightning invoice has already been paid before to prevent duplicate payments of the same invoice.

This PR will do a wallet db upgrade!

@f321x f321x force-pushed the enforce_requested_min_final_cltv_delta branch 3 times, most recently from 762ff95 to 1b9017f Compare September 3, 2025 14:16
@f321x f321x marked this pull request as draft September 4, 2025 07:48
Add `test_reject_invalid_min_final_cltv_delta` which is supposed to test
that the peer rejects incoming htlcs with final cltv delta differing
from what has been requested in the lightning invoice.
Adds the min_final_cltv_delta value to PaymentInfo so that it is
possible to verify it later when receiving the htlcs in lnpeer.
Currently the min_final_cltv_delta which was used in get_bolt11_invoice
for the lightning invoice was not persisted (except maybe through the
invoice in a Request object), so it was not possible to verify it when
receiving htlcs.
get_bolt11_invoice is now dependent on PaymentInfo being available, so
PaymentInfo has to be created first. This is done to prevent creating a
bolt11 invoice with different min_final_cltv_delta than the value stored
in PaymentInfo.
Version 60 to 61, converts the PaymentInfo tuple into the PaymentInfo
dataclass.
This ensures that invoices can only be created if PaymentInfo has been
created first. It also ensures that the values in PaymentInfo are
similar to the values shared in the invoice.
Enforces the min_final_cltv_delta and expiry the receiver of the payment
has requested from the sender through the lightning invoice.
Test that lnpeer is rejecting incoming htlcs for invoices that are
already expired.
Test that lnpeer rejects incoming htlcs for payments that have already
been paid so invoices cannot be paid twice.
Reject new incoming htlcs for requests that have already been paid
before.
@f321x f321x force-pushed the enforce_requested_min_final_cltv_delta branch from 1b9017f to 3dad647 Compare September 4, 2025 15:10
@f321x
Copy link
Member Author

f321x commented Sep 19, 2025

Closed in favor of #10230

@f321x f321x closed this Sep 19, 2025
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.

1 participant