Skip to content

Commit 4923990

Browse files
committed
Correct MIN_FINAL_CLTV_EXPIRY to match our enforced requirements
Our enforced requirements for HTLC acceptance is that we have at least HTLC_FAIL_BACK_BUFFER blocks before the HTLC expires. When we receive an HTLC, the HTLC would be "already expired" if its `cltv_expiry` is current-block + 1 (ie the next block could broadcast the commitment transaction and time out the HTLC). From there, we want an extra HTLC_FAIL_BACK_BUFFER in blocks, plus an extra block or two to account for any differences in the view of the current height before send or while the HTLC is transiting the network.
1 parent 6809f2b commit 4923990

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,13 @@ pub(crate) const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 2 * 6 * 24 * 7;
575575
pub const MIN_CLTV_EXPIRY_DELTA: u16 = 6*7;
576576
pub(super) const CLTV_FAR_FAR_AWAY: u32 = 6 * 24 * 7; //TODO?
577577

578+
// Note that we fail if exactly HTLC_FAIL_BACK_BUFFER + 1 was used, so we need to add one for
579+
// any payments to succeed. Further, we don't want payments to fail if a block was found while
580+
// a payment was being routed, so we add an extra block to be safe.
578581
/// Minimum CLTV difference between the current block height and received inbound payments.
579582
/// Invoices generated for payment to us must set their `min_final_cltv_expiry` field to at least
580583
/// this value.
581-
pub const MIN_FINAL_CLTV_EXPIRY: u32 = HTLC_FAIL_BACK_BUFFER;
584+
pub const MIN_FINAL_CLTV_EXPIRY: u32 = HTLC_FAIL_BACK_BUFFER + 3;
582585

583586
// Check that our CLTV_EXPIRY is at least CLTV_CLAIM_BUFFER + ANTI_REORG_DELAY + LATENCY_GRACE_PERIOD_BLOCKS,
584587
// ie that if the next-hop peer fails the HTLC within

0 commit comments

Comments
 (0)