Skip to content

Commit 90a4220

Browse files
committed
Allow overshooting final cltv_expiry
Final nodes previously had stricter requirements on HTLC contents matching onion value compared to intermediate nodes. This allowed for probing, i.e. the last intermediate node could overshoot the value by a small amount and conclude from the acceptance or rejection of the HTLC whether the next node was the destination. This also applies to the msat amount, however this change was already present.
1 parent 0708966 commit 90a4220

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,9 +2022,9 @@ where
20222022
payment_hash: PaymentHash, amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>) -> Result<PendingHTLCInfo, ReceiveError>
20232023
{
20242024
// final_incorrect_cltv_expiry
2025-
if hop_data.outgoing_cltv_value != cltv_expiry {
2025+
if hop_data.outgoing_cltv_value > cltv_expiry {
20262026
return Err(ReceiveError {
2027-
msg: "Upstream node set CLTV to the wrong value",
2027+
msg: "Upstream node set CLTV to less than outgoing CLTV",
20282028
err_code: 18,
20292029
err_data: cltv_expiry.to_be_bytes().to_vec()
20302030
})

lightning/src/ln/onion_route_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ fn test_onion_failure() {
552552
for f in pending_forwards.iter_mut() {
553553
match f {
554554
&mut HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo { ref mut forward_info, .. }) =>
555-
forward_info.outgoing_cltv_value += 1,
555+
forward_info.outgoing_cltv_value -= 1,
556556
_ => {},
557557
}
558558
}
@@ -1096,7 +1096,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
10961096
&mut HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
10971097
forward_info: PendingHTLCInfo { ref mut outgoing_cltv_value, .. }, ..
10981098
}) => {
1099-
*outgoing_cltv_value += 1;
1099+
*outgoing_cltv_value -= 1;
11001100
},
11011101
_ => panic!("Unexpected forward"),
11021102
}
@@ -1114,7 +1114,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
11141114
commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false);
11151115

11161116
// Ensure the payment fails with the expected error.
1117-
let expected_cltv: u32 = 82;
1117+
let expected_cltv: u32 = 80;
11181118
let error_data = expected_cltv.to_be_bytes().to_vec();
11191119
let mut fail_conditions = PaymentFailedConditions::new()
11201120
.blamed_scid(phantom_scid)

0 commit comments

Comments
 (0)