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