@@ -2407,6 +2407,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> {
2407
2407
pub clear_recipient_events : bool ,
2408
2408
pub expected_preimage : Option < PaymentPreimage > ,
2409
2409
pub is_probe : bool ,
2410
+ // Allow overpayment to the recipient up to this amount. Useful for payments to blinded paths
2411
+ // where rounding errors during `BlindedPayInfo` aggregation may result in overpayment.
2412
+ pub overpay_limit : u64 ,
2410
2413
}
2411
2414
2412
2415
impl < ' a , ' b , ' c , ' d > PassAlongPathArgs < ' a , ' b , ' c , ' d > {
@@ -2417,7 +2420,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2417
2420
Self {
2418
2421
origin_node, expected_path, recv_value, payment_hash, payment_secret : None , event,
2419
2422
payment_claimable_expected : true , clear_recipient_events : true , expected_preimage : None ,
2420
- is_probe : false ,
2423
+ is_probe : false , overpay_limit : 0 ,
2421
2424
}
2422
2425
}
2423
2426
pub fn clear_recipient_events ( mut self , clear_recipient_events : bool ) -> Self {
@@ -2441,13 +2444,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
2441
2444
self . expected_preimage = Some ( payment_preimage) ;
2442
2445
self
2443
2446
}
2447
+ pub fn with_overpay_limit ( mut self , overpay_limit : u64 ) -> Self {
2448
+ self . overpay_limit = overpay_limit;
2449
+ self
2450
+ }
2444
2451
}
2445
2452
2446
2453
pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
2447
2454
let PassAlongPathArgs {
2448
2455
origin_node, expected_path, recv_value, payment_hash : our_payment_hash,
2449
2456
payment_secret : our_payment_secret, event : ev, payment_claimable_expected,
2450
- clear_recipient_events, expected_preimage, is_probe
2457
+ clear_recipient_events, expected_preimage, is_probe, overpay_limit ,
2451
2458
} = args;
2452
2459
2453
2460
let mut payment_event = SendEvent :: from_event ( ev) ;
@@ -2491,7 +2498,8 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
2491
2498
assert_eq ! ( our_payment_secret, onion_fields. as_ref( ) . unwrap( ) . payment_secret) ;
2492
2499
} ,
2493
2500
}
2494
- assert_eq ! ( * amount_msat, recv_value) ;
2501
+ assert ! ( * amount_msat >= recv_value) ;
2502
+ assert ! ( * amount_msat <= recv_value + overpay_limit) ;
2495
2503
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. channel_id == via_channel_id. unwrap( ) ) ) ;
2496
2504
assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. user_channel_id == via_user_channel_id. unwrap( ) ) ) ;
2497
2505
assert ! ( claim_deadline. unwrap( ) > node. best_block_info( ) . 1 ) ;
0 commit comments