Skip to content

Commit 248f247

Browse files
f always add shadow offset to blinded paths
1 parent 742e2ba commit 248f247

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lightning/src/routing/router.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,8 +2111,6 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
21112111
let network_nodes = network_graph.nodes();
21122112

21132113
for path in route.paths.iter_mut() {
2114-
if path.blinded_tail.as_ref().map_or(false, |tail| tail.hops.len() > 1) { continue }
2115-
21162114
let mut shadow_ctlv_expiry_delta_offset: u32 = 0;
21172115

21182116
// Remember the last three nodes of the random walk and avoid looping back on them.
@@ -2184,8 +2182,7 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
21842182
if let Some(tail) = path.blinded_tail.as_mut() {
21852183
tail.final_cltv_expiry_delta = tail.final_cltv_expiry_delta
21862184
.checked_add(shadow_ctlv_expiry_delta_offset).unwrap_or(tail.final_cltv_expiry_delta);
2187-
}
2188-
if let Some(last_hop) = path.hops.last_mut() {
2185+
} else if let Some(last_hop) = path.hops.last_mut() {
21892186
last_hop.cltv_expiry_delta = last_hop.cltv_expiry_delta
21902187
.checked_add(shadow_ctlv_expiry_delta_offset).unwrap_or(last_hop.cltv_expiry_delta);
21912188
}
@@ -5880,7 +5877,7 @@ mod tests {
58805877

58815878
#[test]
58825879
fn blinded_path_cltv_shadow_offset() {
5883-
// Don't add a shadow offset to blinded paths with more than 1 hop.
5880+
// Make sure we add a shadow offset when sending to blinded paths.
58845881
let blinded_path = BlindedPath {
58855882
introduction_node_id: ln_test_utils::pubkey(43),
58865883
blinding_point: ln_test_utils::pubkey(44),
@@ -5918,11 +5915,6 @@ mod tests {
59185915
let payment_params = PaymentParameters::from_node_id(ln_test_utils::pubkey(47), 18);
59195916
let (_, network_graph, _, _, _) = build_line_graph();
59205917
add_random_cltv_offset(&mut route, &payment_params, &network_graph.read_only(), &[0; 32]);
5921-
assert_eq!(route.paths[0].blinded_tail.as_ref().unwrap().final_cltv_expiry_delta, 0);
5922-
5923-
// Add a shadow offset if we're sending to a 1-hop blinded path.
5924-
route.paths[0].blinded_tail.as_mut().unwrap().hops.pop();
5925-
add_random_cltv_offset(&mut route, &payment_params, &network_graph.read_only(), &[0; 32]);
59265918
assert_eq!(route.paths[0].blinded_tail.as_ref().unwrap().final_cltv_expiry_delta, 40);
59275919
}
59285920
}

0 commit comments

Comments
 (0)