Skip to content

Allow configurable per-payment min_final_cltv_expiry #1850

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

Closed
TheBlueMatt opened this issue Nov 14, 2022 · 3 comments · Fixed by #1878
Closed

Allow configurable per-payment min_final_cltv_expiry #1850

TheBlueMatt opened this issue Nov 14, 2022 · 3 comments · Fixed by #1878
Assignees
Milestone

Comments

@TheBlueMatt
Copy link
Collaborator

This is actually really important for some users (ie those doing swaps). We currently require users just use the hard-coded LDK final_cltv_expiry values. To change this, we'll need to encode the min_final_cltv_expiry value in the payment secret in ( in the inbound_payment.rs form), which will get pretty packed.

I think we can do it, though - we only really need to store a min_final_cltv_expiry up to a few days, maybe a week. If we use 12 bits for the expiry, that gives us up to ~28.5 days worth of expiry, and no one should really be creating HTLCs that last longer than that anyway. We can pretty easily take 8 or 9 bits from the expiry time we store in the payment_secret - we only compare it to the block height, which is basically +/- 600 sec anyway, so let's say we take 8 bits and round down to the nearest 256. Now we have to shave 4 bits off the amount, which already lost 3 bits on the payment type (we'll have to add two new payment types, but that still leaves 4). This leaves 57 bits for amount, or 1.44 million BTC, which I this is more than enough for any single payment.

@TheBlueMatt TheBlueMatt modified the milestones: 0.1.1, 0.0.114 Nov 14, 2022
@TheBlueMatt
Copy link
Collaborator Author

Tagging 114 since users want this.

@TheBlueMatt
Copy link
Collaborator Author

Also we need lightning-invoice utils to construct invoices with different expiries.

@dunxen
Copy link
Contributor

dunxen commented Nov 21, 2022

Ok, I can work on this one when I need dual-funding breaks :)

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 a pull request may close this issue.

2 participants