You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lightning/src/ln/channelmanager.rs
+15-4Lines changed: 15 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ use secp256k1;
28
28
use chain::chaininterface::{BroadcasterInterface,ChainListener,FeeEstimator};
29
29
use chain::transaction::OutPoint;
30
30
use ln::channel::{Channel,ChannelError};
31
-
use ln::channelmonitor::{ChannelMonitor,ChannelMonitorUpdate,ChannelMonitorUpdateErr,ManyChannelMonitor,CLTV_CLAIM_BUFFER,LATENCY_GRACE_PERIOD_BLOCKS,ANTI_REORG_DELAY,HTLC_FAIL_BACK_BUFFER};
31
+
use ln::channelmonitor::{ChannelMonitor,ChannelMonitorUpdate,ChannelMonitorUpdateErr,ManyChannelMonitor,HTLC_FAIL_BACK_BUFFER,CLTV_CLAIM_BUFFER,LATENCY_GRACE_PERIOD_BLOCKS,ANTI_REORG_DELAY};
breakSome(("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())));
1164
1168
}
1165
1169
let cur_height = self.latest_block_height.load(Ordering::Acquire)asu32 + 1;
1166
-
// We want to have at least LATENCY_GRACE_PERIOD_BLOCKS to fail prior to going on chain CLAIM_BUFFER blocks before expiration
1167
-
if msg.cltv_expiry <= cur_height + CLTV_CLAIM_BUFFER + LATENCY_GRACE_PERIOD_BLOCKSasu32{// expiry_too_soon
1170
+
// Theoretically, channel counterparty shouldn't send us a HTLC expiring now, but we want to be robust wrt to counterparty
1171
+
// packet sanitization (see HTLC_FAIL_BACK_BUFFER rational)
1172
+
if msg.cltv_expiry <= cur_height + HTLC_FAIL_BACK_BUFFERasu32{// expiry_too_soon
1168
1173
breakSome(("CLTV expiry is too close",0x1000 | 14,Some(self.get_channel_update(chan).unwrap())));
1169
1174
}
1170
1175
if msg.cltv_expiry > cur_height + CLTV_FAR_FAR_AWAYasu32{// expiry_too_far
1171
1176
breakSome(("CLTV expiry is too far in the future",21,None));
1172
1177
}
1178
+
// In theory, we would be safe against unitentional channel-closure, if we only required a margin of LATENCY_GRACE_PERIOD_BLOCKS.
1179
+
// But, to be safe against policy reception, we use a longuer delay.
0 commit comments