@@ -2492,6 +2492,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> {
2492
2492
pub clear_recipient_events : bool ,
2493
2493
pub expected_preimage : Option < PaymentPreimage > ,
2494
2494
pub is_probe : bool ,
2495
+ // Allow overpayment to the recipient up to this amount. Useful for payments to blinded paths
2496
+ // where rounding errors during `BlindedPayInfo` aggregation may result in overpayment.
2497
+ pub overpay_limit : u64 ,
2495
2498
}
2496
2499
2497
2500
impl < ' a , ' b , ' c , ' d > PassAlongPathArgs < ' a , ' b , ' c , ' d > {
@@ -2502,7 +2505,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2502
2505
Self {
2503
2506
origin_node, expected_path, recv_value, payment_hash, payment_secret : None , event,
2504
2507
payment_claimable_expected : true , clear_recipient_events : true , expected_preimage : None ,
2505
- is_probe : false ,
2508
+ is_probe : false , overpay_limit : 0 ,
2506
2509
}
2507
2510
}
2508
2511
pub fn clear_recipient_events ( mut self , clear_recipient_events : bool ) -> Self {
@@ -2526,13 +2529,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2526
2529
self . expected_preimage = Some ( payment_preimage) ;
2527
2530
self
2528
2531
}
2532
+ pub fn with_overpay_limit ( mut self , overpay_limit : u64 ) -> Self {
2533
+ self . overpay_limit = overpay_limit;
2534
+ self
2535
+ }
2529
2536
}
2530
2537
2531
2538
pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
2532
2539
let PassAlongPathArgs {
2533
2540
origin_node, expected_path, recv_value, payment_hash : our_payment_hash,
2534
2541
payment_secret : our_payment_secret, event : ev, payment_claimable_expected,
2535
- clear_recipient_events, expected_preimage, is_probe
2542
+ clear_recipient_events, expected_preimage, is_probe, overpay_limit ,
2536
2543
} = args;
2537
2544
2538
2545
let mut payment_event = SendEvent :: from_event ( ev) ;
@@ -2576,7 +2583,8 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
2576
2583
assert_eq ! ( our_payment_secret, onion_fields. as_ref( ) . unwrap( ) . payment_secret) ;
2577
2584
} ,
2578
2585
}
2579
- assert_eq ! ( * amount_msat, recv_value) ;
2586
+ assert ! ( * amount_msat >= recv_value) ;
2587
+ assert ! ( * amount_msat <= recv_value + overpay_limit) ;
2580
2588
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. channel_id == via_channel_id. unwrap( ) ) ) ;
2581
2589
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. user_channel_id == via_user_channel_id. unwrap( ) ) ) ;
2582
2590
assert ! ( claim_deadline. unwrap( ) > node. best_block_info( ) . 1 ) ;
0 commit comments