@@ -175,13 +175,7 @@ impl InFlightHtlcs {
175
175
176
176
let mut cumulative_msat = 0 ;
177
177
if let Some ( tail) = & path. blinded_tail {
178
- cumulative_msat += tail. final_value_msat + tail. fee_msat ;
179
- self . 0
180
- . entry ( ( tail. intro_node_scid ,
181
- NodeId :: from_pubkey ( & path. hops . last ( ) . map_or ( payer_node_id, |hop| hop. pubkey ) ) <
182
- NodeId :: from_pubkey ( & tail. path . introduction_node_id ) ) )
183
- . and_modify ( |used_liquidity_msat| * used_liquidity_msat += cumulative_msat)
184
- . or_insert ( cumulative_msat) ;
178
+ cumulative_msat += tail. final_value_msat ;
185
179
}
186
180
187
181
// total_inflight_map needs to be direction-sensitive when keeping track of the HTLC value
@@ -303,7 +297,7 @@ pub struct Path {
303
297
impl Path {
304
298
/// The length of this path, including the hops of its [`Path::blinded_tail`], if any.
305
299
pub fn len ( & self ) -> usize {
306
- self . hops . len ( ) + self . blinded_tail . as_ref ( ) . map_or ( 0 , |tail| tail. path . blinded_hops . len ( ) )
300
+ self . hops . len ( ) + self . blinded_tail . as_ref ( ) . map_or ( 0 , |tail| tail. hops . len ( ) . saturating_sub ( 1 ) ) // Don't double count the intro node
307
301
}
308
302
}
309
303
@@ -2264,7 +2258,7 @@ fn build_route_from_hops_internal<L: Deref>(
2264
2258
2265
2259
#[ cfg( test) ]
2266
2260
mod tests {
2267
- use crate :: blinded_path:: BlindedPath ;
2261
+ use crate :: blinded_path:: { BlindedHop , BlindedPath } ;
2268
2262
use crate :: routing:: gossip:: { NetworkGraph , P2PGossipSync , NodeId , EffectiveCapacity } ;
2269
2263
use crate :: routing:: utxo:: UtxoResult ;
2270
2264
use crate :: routing:: router:: { get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
@@ -5768,8 +5762,14 @@ mod tests {
5768
5762
5769
5763
#[ test]
5770
5764
fn blinded_path_inflight_processing ( ) {
5771
- // Ensure we'll score the channel that's inbound to a blinded path's introduction node.
5765
+ // Ensure we'll score the channel that's inbound to a blinded path's introduction node, and
5766
+ // account for the blinded tail's final amount_msat.
5772
5767
let mut inflight_htlcs = InFlightHtlcs :: new ( ) ;
5768
+ let blinded_path = BlindedPath {
5769
+ introduction_node_id : ln_test_utils:: pubkey ( 43 ) ,
5770
+ blinding_point : ln_test_utils:: pubkey ( 48 ) ,
5771
+ blinded_hops : vec ! [ BlindedHop { blinded_node_id: ln_test_utils:: pubkey( 49 ) , encrypted_payload: Vec :: new( ) } ] ,
5772
+ } ;
5773
5773
let path = Path {
5774
5774
hops : vec ! [ RouteHop {
5775
5775
pubkey: ln_test_utils:: pubkey( 42 ) ,
@@ -5778,16 +5778,19 @@ mod tests {
5778
5778
channel_features: ChannelFeatures :: empty( ) ,
5779
5779
fee_msat: 100 ,
5780
5780
cltv_expiry_delta: 0 ,
5781
- } ] ,
5782
- blinded_tail : Some ( BlindedTail {
5783
- path : BlindedPath {
5784
- introduction_node_id : ln_test_utils:: pubkey ( 43 ) ,
5785
- blinding_point : ln_test_utils:: pubkey ( 44 ) ,
5786
- blinded_hops : Vec :: new ( ) ,
5787
- } ,
5788
- intro_node_scid : 43 ,
5781
+ } ,
5782
+ RouteHop {
5783
+ pubkey: blinded_path. introduction_node_id,
5784
+ node_features: NodeFeatures :: empty( ) ,
5785
+ short_channel_id: 43 ,
5786
+ channel_features: ChannelFeatures :: empty( ) ,
5789
5787
fee_msat: 1 ,
5790
5788
cltv_expiry_delta: 0 ,
5789
+ } ] ,
5790
+ blinded_tail : Some ( BlindedTail {
5791
+ hops : blinded_path. blinded_hops ,
5792
+ blinding_point : blinded_path. blinding_point ,
5793
+ final_cltv_expiry_delta : 0 ,
5791
5794
final_value_msat : 200 ,
5792
5795
} ) ,
5793
5796
} ;
0 commit comments