From 8cc0919f9d438ab77865cd8bb7db872795a21648 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Thu, 9 Apr 2020 21:22:16 -0400 Subject: [PATCH] Document exactly our CLTV sanitization policy for incoming HTLCs --- lightning/src/ln/channelmanager.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index f9ccc18a0..4f71f406b 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -1160,7 +1160,8 @@ impl ChannelMan break Some(("Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta", 0x1000 | 13, Some(self.get_channel_update(chan).unwrap()))); } let cur_height = self.latest_block_height.load(Ordering::Acquire) as u32 + 1; - // We want to have at least LATENCY_GRACE_PERIOD_BLOCKS to fail prior to going on chain CLAIM_BUFFER blocks before expiration + // Theoritically, channel counterparty shouldn't send us a HLC expiring now, but we want to be robust wrt to counterparty + // packet sanitization. if msg.cltv_expiry <= cur_height + CLTV_CLAIM_BUFFER + LATENCY_GRACE_PERIOD_BLOCKS as u32 { // expiry_too_soon break Some(("CLTV expiry is too close", 0x1000 | 14, Some(self.get_channel_update(chan).unwrap()))); } -- 2.39.5