@@ -2102,9 +2102,10 @@ where L::Target: Logger {
2102
2102
Some ( fee) => fee,
2103
2103
None => continue
2104
2104
} ;
2105
+ let path_min = candidate. htlc_minimum_msat ( ) . saturating_add (
2106
+ compute_fees_saturating ( candidate. htlc_minimum_msat ( ) , candidate. fees ( ) ) ) ;
2105
2107
add_entry ! ( first_hop_candidate, our_node_id, intro_node_id, blinded_path_fee,
2106
- path_contribution_msat, candidate. htlc_minimum_msat( ) , 0_u64 ,
2107
- candidate. cltv_expiry_delta( ) ,
2108
+ path_contribution_msat, path_min, 0_u64 , candidate. cltv_expiry_delta( ) ,
2108
2109
candidate. blinded_path( ) . map_or( 1 , |bp| bp. blinded_hops. len( ) as u8 ) ) ;
2109
2110
}
2110
2111
}
@@ -7286,6 +7287,10 @@ mod tests {
7286
7287
7287
7288
#[ test]
7288
7289
fn min_htlc_overpay_violates_max_htlc ( ) {
7290
+ do_min_htlc_overpay_violates_max_htlc ( true ) ;
7291
+ do_min_htlc_overpay_violates_max_htlc ( false ) ;
7292
+ }
7293
+ fn do_min_htlc_overpay_violates_max_htlc ( blinded_payee : bool ) {
7289
7294
// Test that if overpaying to meet a later hop's min_htlc and causes us to violate an earlier
7290
7295
// hop's max_htlc, we don't consider that candidate hop valid. Previously we would add this hop
7291
7296
// to `targets` and build an invalid path with it, and subsquently hit a debug panic asserting
@@ -7309,7 +7314,27 @@ mod tests {
7309
7314
7310
7315
let base_fee = 1_6778_3453 ;
7311
7316
let htlc_min = 2_5165_8240 ;
7312
- let payment_params = {
7317
+ let payment_params = if blinded_payee {
7318
+ let blinded_path = BlindedPath {
7319
+ introduction_node_id : nodes[ 0 ] ,
7320
+ blinding_point : ln_test_utils:: pubkey ( 42 ) ,
7321
+ blinded_hops : vec ! [
7322
+ BlindedHop { blinded_node_id: ln_test_utils:: pubkey( 42 as u8 ) , encrypted_payload: Vec :: new( ) } ,
7323
+ BlindedHop { blinded_node_id: ln_test_utils:: pubkey( 42 as u8 ) , encrypted_payload: Vec :: new( ) }
7324
+ ] ,
7325
+ } ;
7326
+ let blinded_payinfo = BlindedPayInfo {
7327
+ fee_base_msat : base_fee,
7328
+ fee_proportional_millionths : 0 ,
7329
+ htlc_minimum_msat : htlc_min,
7330
+ htlc_maximum_msat : htlc_min * 1000 ,
7331
+ cltv_expiry_delta : 0 ,
7332
+ features : BlindedHopFeatures :: empty ( ) ,
7333
+ } ;
7334
+ let bolt12_features: Bolt12InvoiceFeatures = channelmanager:: provided_invoice_features ( & config) . to_context ( ) ;
7335
+ PaymentParameters :: blinded ( vec ! [ ( blinded_payinfo, blinded_path) ] )
7336
+ . with_bolt12_features ( bolt12_features. clone ( ) ) . unwrap ( )
7337
+ } else {
7313
7338
let route_hint = RouteHint ( vec ! [ RouteHintHop {
7314
7339
src_node_id: nodes[ 0 ] ,
7315
7340
short_channel_id: 42 ,
@@ -7340,6 +7365,11 @@ mod tests {
7340
7365
7341
7366
#[ test]
7342
7367
fn previously_used_liquidity_violates_max_htlc ( ) {
7368
+ do_previously_used_liquidity_violates_max_htlc ( true ) ;
7369
+ do_previously_used_liquidity_violates_max_htlc ( false ) ;
7370
+
7371
+ }
7372
+ fn do_previously_used_liquidity_violates_max_htlc ( blinded_payee : bool ) {
7343
7373
// Test that if a candidate first_hop<>route_hint_src_node channel does not have enough
7344
7374
// contribution amount to cover the next hop's min_htlc plus fees, we will not consider that
7345
7375
// candidate. In this case, the candidate does not have enough due to a previous path taking up
@@ -7364,7 +7394,30 @@ mod tests {
7364
7394
7365
7395
let base_fees = [ 0 , 425_9840 , 0 , 0 ] ;
7366
7396
let htlc_mins = [ 1_4392 , 19_7401 , 1027 , 6_5535 ] ;
7367
- let payment_params = {
7397
+ let payment_params = if blinded_payee {
7398
+ let blinded_path = BlindedPath {
7399
+ introduction_node_id : nodes[ 0 ] ,
7400
+ blinding_point : ln_test_utils:: pubkey ( 42 ) ,
7401
+ blinded_hops : vec ! [
7402
+ BlindedHop { blinded_node_id: ln_test_utils:: pubkey( 42 as u8 ) , encrypted_payload: Vec :: new( ) } ,
7403
+ BlindedHop { blinded_node_id: ln_test_utils:: pubkey( 42 as u8 ) , encrypted_payload: Vec :: new( ) }
7404
+ ] ,
7405
+ } ;
7406
+ let mut blinded_hints = Vec :: new ( ) ;
7407
+ for ( base_fee, htlc_min) in base_fees. iter ( ) . zip ( htlc_mins. iter ( ) ) {
7408
+ blinded_hints. push ( ( BlindedPayInfo {
7409
+ fee_base_msat : * base_fee,
7410
+ fee_proportional_millionths : 0 ,
7411
+ htlc_minimum_msat : * htlc_min,
7412
+ htlc_maximum_msat : htlc_min * 100 ,
7413
+ cltv_expiry_delta : 10 ,
7414
+ features : BlindedHopFeatures :: empty ( ) ,
7415
+ } , blinded_path. clone ( ) ) ) ;
7416
+ }
7417
+ let bolt12_features: Bolt12InvoiceFeatures = channelmanager:: provided_invoice_features ( & config) . to_context ( ) ;
7418
+ PaymentParameters :: blinded ( blinded_hints. clone ( ) )
7419
+ . with_bolt12_features ( bolt12_features. clone ( ) ) . unwrap ( )
7420
+ } else {
7368
7421
let mut route_hints = Vec :: new ( ) ;
7369
7422
for ( idx, ( base_fee, htlc_min) ) in base_fees. iter ( ) . zip ( htlc_mins. iter ( ) ) . enumerate ( ) {
7370
7423
route_hints. push ( RouteHint ( vec ! [ RouteHintHop {
0 commit comments