@@ -172,6 +172,12 @@ impl InFlightHtlcs {
172172 /// Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`.
173173 pub fn process_path ( & mut self , path : & Path , payer_node_id : PublicKey ) {
174174 if path. hops . is_empty ( ) { return } ;
175+
176+ let mut cumulative_msat = 0 ;
177+ if let Some ( tail) = & path. blinded_tail {
178+ cumulative_msat += tail. final_value_msat ;
179+ }
180+
175181 // total_inflight_map needs to be direction-sensitive when keeping track of the HTLC value
176182 // that is held up. However, the `hops` array, which is a path returned by `find_route` in
177183 // the router excludes the payer node. In the following lines, the payer's information is
@@ -180,7 +186,6 @@ impl InFlightHtlcs {
180186 let reversed_hops_with_payer = path. hops . iter ( ) . rev ( ) . skip ( 1 )
181187 . map ( |hop| hop. pubkey )
182188 . chain ( core:: iter:: once ( payer_node_id) ) ;
183- let mut cumulative_msat = 0 ;
184189
185190 // Taking the reversed vector from above, we zip it with just the reversed hops list to
186191 // work "backwards" of the given path, since the last hop's `fee_msat` actually represents
@@ -2267,7 +2272,7 @@ mod tests {
22672272 use crate :: routing:: gossip:: { NetworkGraph , P2PGossipSync , NodeId , EffectiveCapacity } ;
22682273 use crate :: routing:: utxo:: UtxoResult ;
22692274 use crate :: routing:: router:: { get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
2270- BlindedTail , Path , PaymentParameters , Route , RouteHint , RouteHintHop , RouteHop , RoutingFees ,
2275+ BlindedTail , InFlightHtlcs , Path , PaymentParameters , Route , RouteHint , RouteHintHop , RouteHop , RoutingFees ,
22712276 DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA , MAX_PATH_LENGTH_ESTIMATE } ;
22722277 use crate :: routing:: scoring:: { ChannelUsage , FixedPenaltyScorer , Score , ProbabilisticScorer , ProbabilisticScoringParameters } ;
22732278 use crate :: routing:: test_utils:: { add_channel, add_or_update_node, build_graph, build_line_graph, id_to_feature_flags, get_nodes, update_channel} ;
@@ -5828,6 +5833,45 @@ mod tests {
58285833 assert_eq ! ( decoded_route. paths[ 0 ] . blinded_tail, route. paths[ 0 ] . blinded_tail) ;
58295834 assert_eq ! ( decoded_route. paths[ 1 ] . blinded_tail, route. paths[ 1 ] . blinded_tail) ;
58305835 }
5836+
5837+ #[ test]
5838+ fn blinded_path_inflight_processing ( ) {
5839+ // Ensure we'll score the channel that's inbound to a blinded path's introduction node, and
5840+ // account for the blinded tail's final amount_msat.
5841+ let mut inflight_htlcs = InFlightHtlcs :: new ( ) ;
5842+ let blinded_path = BlindedPath {
5843+ introduction_node_id : ln_test_utils:: pubkey ( 43 ) ,
5844+ blinding_point : ln_test_utils:: pubkey ( 48 ) ,
5845+ blinded_hops : vec ! [ BlindedHop { blinded_node_id: ln_test_utils:: pubkey( 49 ) , encrypted_payload: Vec :: new( ) } ] ,
5846+ } ;
5847+ let path = Path {
5848+ hops : vec ! [ RouteHop {
5849+ pubkey: ln_test_utils:: pubkey( 42 ) ,
5850+ node_features: NodeFeatures :: empty( ) ,
5851+ short_channel_id: 42 ,
5852+ channel_features: ChannelFeatures :: empty( ) ,
5853+ fee_msat: 100 ,
5854+ cltv_expiry_delta: 0 ,
5855+ } ,
5856+ RouteHop {
5857+ pubkey: blinded_path. introduction_node_id,
5858+ node_features: NodeFeatures :: empty( ) ,
5859+ short_channel_id: 43 ,
5860+ channel_features: ChannelFeatures :: empty( ) ,
5861+ fee_msat: 1 ,
5862+ cltv_expiry_delta: 0 ,
5863+ } ] ,
5864+ blinded_tail : Some ( BlindedTail {
5865+ hops : blinded_path. blinded_hops ,
5866+ blinding_point : blinded_path. blinding_point ,
5867+ excess_final_cltv_expiry_delta : 0 ,
5868+ final_value_msat : 200 ,
5869+ } ) ,
5870+ } ;
5871+ inflight_htlcs. process_path ( & path, ln_test_utils:: pubkey ( 44 ) ) ;
5872+ assert_eq ! ( * inflight_htlcs. 0 . get( & ( 42 , true ) ) . unwrap( ) , 301 ) ;
5873+ assert_eq ! ( * inflight_htlcs. 0 . get( & ( 43 , false ) ) . unwrap( ) , 201 ) ;
5874+ }
58315875}
58325876
58335877#[ cfg( all( test, not( feature = "no-std" ) ) ) ]
0 commit comments