@@ -2111,8 +2111,6 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
2111
2111
let network_nodes = network_graph. nodes ( ) ;
2112
2112
2113
2113
for path in route. paths . iter_mut ( ) {
2114
- if path. blinded_tail . as_ref ( ) . map_or ( false , |tail| tail. hops . len ( ) > 1 ) { continue }
2115
-
2116
2114
let mut shadow_ctlv_expiry_delta_offset: u32 = 0 ;
2117
2115
2118
2116
// 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,
2184
2182
if let Some ( tail) = path. blinded_tail . as_mut ( ) {
2185
2183
tail. final_cltv_expiry_delta = tail. final_cltv_expiry_delta
2186
2184
. 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 ( ) {
2189
2186
last_hop. cltv_expiry_delta = last_hop. cltv_expiry_delta
2190
2187
. checked_add ( shadow_ctlv_expiry_delta_offset) . unwrap_or ( last_hop. cltv_expiry_delta ) ;
2191
2188
}
@@ -5880,7 +5877,7 @@ mod tests {
5880
5877
5881
5878
#[ test]
5882
5879
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.
5884
5881
let blinded_path = BlindedPath {
5885
5882
introduction_node_id : ln_test_utils:: pubkey ( 43 ) ,
5886
5883
blinding_point : ln_test_utils:: pubkey ( 44 ) ,
@@ -5918,11 +5915,6 @@ mod tests {
5918
5915
let payment_params = PaymentParameters :: from_node_id ( ln_test_utils:: pubkey ( 47 ) , 18 ) ;
5919
5916
let ( _, network_graph, _, _, _) = build_line_graph ( ) ;
5920
5917
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 ] ) ;
5926
5918
assert_eq ! ( route. paths[ 0 ] . blinded_tail. as_ref( ) . unwrap( ) . final_cltv_expiry_delta, 40 ) ;
5927
5919
}
5928
5920
}
0 commit comments