@@ -2426,6 +2426,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> {
2426
2426
pub clear_recipient_events : bool ,
2427
2427
pub expected_preimage : Option < PaymentPreimage > ,
2428
2428
pub is_probe : bool ,
2429
+ // Allow overpayment to the recipient up to this amount. Useful for payments to blinded paths
2430
+ // where rounding errors during `BlindedPayInfo` aggregation may result in overpayment.
2431
+ pub overpay_limit : u64 ,
2429
2432
}
2430
2433
2431
2434
impl < ' a , ' b , ' c , ' d > PassAlongPathArgs < ' a , ' b , ' c , ' d > {
@@ -2436,7 +2439,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2436
2439
Self {
2437
2440
origin_node, expected_path, recv_value, payment_hash, payment_secret : None , event,
2438
2441
payment_claimable_expected : true , clear_recipient_events : true , expected_preimage : None ,
2439
- is_probe : false ,
2442
+ is_probe : false , overpay_limit : 0 ,
2440
2443
}
2441
2444
}
2442
2445
pub fn clear_recipient_events ( mut self , clear_recipient_events : bool ) -> Self {
@@ -2460,13 +2463,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2460
2463
self . expected_preimage = Some ( payment_preimage) ;
2461
2464
self
2462
2465
}
2466
+ pub fn with_overpay_limit ( mut self , overpay_limit : u64 ) -> Self {
2467
+ self . overpay_limit = overpay_limit;
2468
+ self
2469
+ }
2463
2470
}
2464
2471
2465
2472
pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
2466
2473
let PassAlongPathArgs {
2467
2474
origin_node, expected_path, recv_value, payment_hash : our_payment_hash,
2468
2475
payment_secret : our_payment_secret, event : ev, payment_claimable_expected,
2469
- clear_recipient_events, expected_preimage, is_probe
2476
+ clear_recipient_events, expected_preimage, is_probe, overpay_limit ,
2470
2477
} = args;
2471
2478
2472
2479
let mut payment_event = SendEvent :: from_event ( ev) ;
@@ -2510,7 +2517,8 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
2510
2517
assert_eq ! ( our_payment_secret, onion_fields. as_ref( ) . unwrap( ) . payment_secret) ;
2511
2518
} ,
2512
2519
}
2513
- assert_eq ! ( * amount_msat, recv_value) ;
2520
+ assert ! ( * amount_msat >= recv_value) ;
2521
+ assert ! ( * amount_msat <= recv_value + overpay_limit) ;
2514
2522
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. channel_id == via_channel_id. unwrap( ) ) ) ;
2515
2523
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. user_channel_id == via_user_channel_id. unwrap( ) ) ) ;
2516
2524
assert ! ( claim_deadline. unwrap( ) > node. best_block_info( ) . 1 ) ;
0 commit comments