@@ -2454,6 +2454,9 @@ where L::Target: Logger {
2454
2454
// because we deterministically terminated the search due to low liquidity.
2455
2455
if !found_new_path && channel_saturation_pow_half != 0 {
2456
2456
channel_saturation_pow_half = 0 ;
2457
+ } else if !found_new_path && hit_minimum_limit && already_collected_value_msat < final_value_msat && path_value_msat != recommended_value_msat {
2458
+ log_trace ! ( logger, "Failed to collect enough value, but running again to collect extra paths with a potentially higher limit." ) ;
2459
+ path_value_msat = recommended_value_msat;
2457
2460
} else if already_collected_value_msat >= recommended_value_msat || !found_new_path {
2458
2461
log_trace ! ( logger, "Have now collected {} msat (seeking {} msat) in paths. Last path loop {} a new path." ,
2459
2462
already_collected_value_msat, recommended_value_msat, if found_new_path { "found" } else { "did not find" } ) ;
@@ -3223,6 +3226,56 @@ mod tests {
3223
3226
assert_eq ! ( fees, 5_000 ) ;
3224
3227
}
3225
3228
3229
+ #[ test]
3230
+ fn htlc_minimum_recipient_overpay_test ( ) {
3231
+ let ( secp_ctx, network_graph, gossip_sync, _, logger) = build_graph ( ) ;
3232
+ let ( _, our_id, privkeys, nodes) = get_nodes ( & secp_ctx) ;
3233
+ let config = UserConfig :: default ( ) ;
3234
+ let payment_params = PaymentParameters :: from_node_id ( nodes[ 2 ] , 42 ) . with_bolt11_features ( channelmanager:: provided_invoice_features ( & config) ) . unwrap ( ) ;
3235
+ let scorer = ln_test_utils:: TestScorer :: new ( ) ;
3236
+ let keys_manager = ln_test_utils:: TestKeysInterface :: new ( & [ 0u8 ; 32 ] , Network :: Testnet ) ;
3237
+ let random_seed_bytes = keys_manager. get_secure_random_bytes ( ) ;
3238
+
3239
+ // Route to node2 over a single path which requires overpaying the recipient themselves.
3240
+
3241
+ // First disable all paths except the us -> node1 -> node2 path
3242
+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 2 ] , UnsignedChannelUpdate {
3243
+ chain_hash : genesis_block ( Network :: Testnet ) . header . block_hash ( ) ,
3244
+ short_channel_id : 13 ,
3245
+ timestamp : 2 ,
3246
+ flags : 3 ,
3247
+ cltv_expiry_delta : 0 ,
3248
+ htlc_minimum_msat : 0 ,
3249
+ htlc_maximum_msat : 0 ,
3250
+ fee_base_msat : 0 ,
3251
+ fee_proportional_millionths : 0 ,
3252
+ excess_data : Vec :: new ( )
3253
+ } ) ;
3254
+
3255
+ // Set channel 4 to free but with a high htlc_minimum_msat
3256
+ update_channel ( & gossip_sync, & secp_ctx, & privkeys[ 1 ] , UnsignedChannelUpdate {
3257
+ chain_hash : genesis_block ( Network :: Testnet ) . header . block_hash ( ) ,
3258
+ short_channel_id : 4 ,
3259
+ timestamp : 2 ,
3260
+ flags : 0 ,
3261
+ cltv_expiry_delta : 0 ,
3262
+ htlc_minimum_msat : 15_000 ,
3263
+ htlc_maximum_msat : MAX_VALUE_MSAT ,
3264
+ fee_base_msat : 0 ,
3265
+ fee_proportional_millionths : 0 ,
3266
+ excess_data : Vec :: new ( )
3267
+ } ) ;
3268
+
3269
+ // Now check that we'll find a path if the htlc_minimum is overrun substantially.
3270
+ let mut route_params = RouteParameters :: from_payment_params_and_value (
3271
+ payment_params. clone ( ) , 5_000 ) ;
3272
+ // TODO: This can even overrun the fee limit set by the recipient!
3273
+ route_params. max_total_routing_fee_msat = Some ( 9_999 ) ;
3274
+ let route = get_route ( & our_id, & route_params, & network_graph. read_only ( ) , None ,
3275
+ Arc :: clone ( & logger) , & scorer, & Default :: default ( ) , & random_seed_bytes) . unwrap ( ) ;
3276
+ assert_eq ! ( route. get_total_fees( ) , 10_000 ) ;
3277
+ }
3278
+
3226
3279
#[ test]
3227
3280
fn disable_channels_test ( ) {
3228
3281
let ( secp_ctx, network_graph, gossip_sync, _, logger) = build_graph ( ) ;
0 commit comments