Skip to content

Commit 4df3797

Browse files
fix: use the update_add_htlc's cltv_expiry for comparison
As noted in BOLT 4, we should be using the update_add_htlc's cltv_expiry, not the CLTV expiry set by the sender in the onion for this comparison. See here: https://github.com/lightning/bolts/blob/4dcc377209509b13cf89a4b91fde7d478f5b46d8/04-onion-routing.md?plain=1#L334
1 parent f405370 commit 4df3797

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,7 +2935,7 @@ where
29352935
// payment logic has enough time to fail the HTLC backward before our onchain logic triggers a
29362936
// channel closure (see HTLC_FAIL_BACK_BUFFER rationale).
29372937
let current_height: u32 = self.best_block.read().unwrap().height();
2938-
if (outgoing_cltv_value as u64) <= current_height as u64 + HTLC_FAIL_BACK_BUFFER as u64 + 1 {
2938+
if (cltv_expiry as u64) <= current_height as u64 + HTLC_FAIL_BACK_BUFFER as u64 + 1 {
29392939
let mut err_data = Vec::with_capacity(12);
29402940
err_data.extend_from_slice(&amt_msat.to_be_bytes());
29412941
err_data.extend_from_slice(&current_height.to_be_bytes());

0 commit comments

Comments
 (0)