@@ -2460,6 +2460,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> {
2460
2460
pub clear_recipient_events : bool ,
2461
2461
pub expected_preimage : Option < PaymentPreimage > ,
2462
2462
pub is_probe : bool ,
2463
+ // Allow overpayment to the recipient up to this amount. Useful for payments to blinded paths
2464
+ // where rounding errors during `BlindedPayInfo` aggregation may result in overpayment.
2465
+ pub overpay_limit : u64 ,
2463
2466
}
2464
2467
2465
2468
impl < ' a , ' b , ' c , ' d > PassAlongPathArgs < ' a , ' b , ' c , ' d > {
@@ -2470,7 +2473,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2470
2473
Self {
2471
2474
origin_node, expected_path, recv_value, payment_hash, payment_secret : None , event,
2472
2475
payment_claimable_expected : true , clear_recipient_events : true , expected_preimage : None ,
2473
- is_probe : false ,
2476
+ is_probe : false , overpay_limit : 0 ,
2474
2477
}
2475
2478
}
2476
2479
pub fn clear_recipient_events ( mut self , clear_recipient_events : bool ) -> Self {
@@ -2494,13 +2497,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2494
2497
self . expected_preimage = Some ( payment_preimage) ;
2495
2498
self
2496
2499
}
2500
+ pub fn with_overpay_limit ( mut self , overpay_limit : u64 ) -> Self {
2501
+ self . overpay_limit = overpay_limit;
2502
+ self
2503
+ }
2497
2504
}
2498
2505
2499
2506
pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
2500
2507
let PassAlongPathArgs {
2501
2508
origin_node, expected_path, recv_value, payment_hash : our_payment_hash,
2502
2509
payment_secret : our_payment_secret, event : ev, payment_claimable_expected,
2503
- clear_recipient_events, expected_preimage, is_probe
2510
+ clear_recipient_events, expected_preimage, is_probe, overpay_limit ,
2504
2511
} = args;
2505
2512
2506
2513
let mut payment_event = SendEvent :: from_event ( ev) ;
@@ -2544,7 +2551,8 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
2544
2551
assert_eq ! ( our_payment_secret, onion_fields. as_ref( ) . unwrap( ) . payment_secret) ;
2545
2552
} ,
2546
2553
}
2547
- assert_eq ! ( * amount_msat, recv_value) ;
2554
+ assert ! ( * amount_msat >= recv_value) ;
2555
+ assert ! ( * amount_msat <= recv_value + overpay_limit) ;
2548
2556
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. channel_id == via_channel_id. unwrap( ) ) ) ;
2549
2557
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. user_channel_id == via_user_channel_id. unwrap( ) ) ) ;
2550
2558
assert ! ( claim_deadline. unwrap( ) > node. best_block_info( ) . 1 ) ;
0 commit comments