@@ -967,7 +967,7 @@ where
967967 let mut htlc_msat = * first_hop_htlc_msat;
968968 let mut _error_code_ret = None ;
969969 let mut _error_packet_ret = None ;
970- let mut is_from_final_node = false ;
970+ let mut is_from_final_non_blinded_node = false ;
971971
972972 const BADONION : u16 = 0x8000 ;
973973 const PERM : u16 = 0x4000 ;
@@ -1011,6 +1011,8 @@ where
10111011 )
10121012 . expect ( "Route we used spontaneously grew invalid keys in the middle of it?" ) ;
10131013
1014+ let num_blinded_hops = path. blinded_tail . as_ref ( ) . map_or ( 0 , |bt| bt. hops . len ( ) ) ;
1015+
10141016 // Handle packed channel/node updates for passing back for the route handler
10151017 let mut iterator = onion_keys. into_iter ( ) . peekable ( ) ;
10161018 while let Some ( ( route_hop_option, shared_secret) ) = iterator. next ( ) {
@@ -1032,10 +1034,9 @@ where
10321034
10331035 // The failing hop includes either the inbound channel to the recipient or the outbound channel
10341036 // from the current hop (i.e., the next hop's inbound channel).
1035- let num_blinded_hops = path. blinded_tail . as_ref ( ) . map_or ( 0 , |bt| bt. hops . len ( ) ) ;
10361037 // For 1-hop blinded paths, the final `path.hops` entry is the recipient.
1037- is_from_final_node = iterator. peek ( ) . is_none ( ) && num_blinded_hops <= 1 ;
1038- let failing_route_hop = if is_from_final_node {
1038+ is_from_final_non_blinded_node = iterator. peek ( ) . is_none ( ) && num_blinded_hops <= 1 ;
1039+ let failing_route_hop = if is_from_final_non_blinded_node {
10391040 route_hop
10401041 } else {
10411042 match iterator. peek ( ) {
@@ -1100,7 +1101,7 @@ where
11001101 res = Some ( FailureLearnings {
11011102 network_update,
11021103 short_channel_id,
1103- payment_failed_permanently : is_from_final_node ,
1104+ payment_failed_permanently : is_from_final_non_blinded_node ,
11041105 failed_within_blinded_path : false ,
11051106 } ) ;
11061107 break ;
@@ -1122,7 +1123,7 @@ where
11221123 res = Some ( FailureLearnings {
11231124 network_update,
11241125 short_channel_id,
1125- payment_failed_permanently : is_from_final_node ,
1126+ payment_failed_permanently : is_from_final_non_blinded_node ,
11261127 failed_within_blinded_path : false ,
11271128 } ) ;
11281129 break ;
@@ -1139,7 +1140,7 @@ where
11391140 let payment_failed = match error_code & 0xff {
11401141 15 | 16 | 17 | 18 | 19 | 23 => true ,
11411142 _ => false ,
1142- } && is_from_final_node ; // PERM bit observed below even if this error is from the intermediate nodes
1143+ } && is_from_final_non_blinded_node ; // PERM bit observed below even if this error is from the intermediate nodes
11431144
11441145 let mut network_update = None ;
11451146 let mut short_channel_id = None ;
@@ -1226,7 +1227,7 @@ where
12261227 res = Some ( FailureLearnings {
12271228 network_update,
12281229 short_channel_id,
1229- payment_failed_permanently : error_code & PERM == PERM && is_from_final_node ,
1230+ payment_failed_permanently : error_code & PERM == PERM && is_from_final_non_blinded_node ,
12301231 failed_within_blinded_path : false ,
12311232 } ) ;
12321233
@@ -1285,7 +1286,7 @@ where
12851286 DecodedOnionFailure {
12861287 network_update : None ,
12871288 short_channel_id : None ,
1288- payment_failed_permanently : is_from_final_node ,
1289+ payment_failed_permanently : is_from_final_non_blinded_node ,
12891290 failed_within_blinded_path : false ,
12901291 #[ cfg( any( test, feature = "_test_utils" ) ) ]
12911292 onion_error_code : None ,
0 commit comments