@@ -2460,6 +2460,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> {
24602460 pub clear_recipient_events : bool ,
24612461 pub expected_preimage : Option < PaymentPreimage > ,
24622462 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 ,
24632466}
24642467
24652468impl < ' a , ' b , ' c , ' d > PassAlongPathArgs < ' a , ' b , ' c , ' d > {
@@ -2470,7 +2473,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
24702473 Self {
24712474 origin_node, expected_path, recv_value, payment_hash, payment_secret : None , event,
24722475 payment_claimable_expected : true , clear_recipient_events : true , expected_preimage : None ,
2473- is_probe : false ,
2476+ is_probe : false , overpay_limit : 0 ,
24742477 }
24752478 }
24762479 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> {
24942497 self . expected_preimage = Some ( payment_preimage) ;
24952498 self
24962499 }
2500+ pub fn with_overpay_limit ( mut self , overpay_limit : u64 ) -> Self {
2501+ self . overpay_limit = overpay_limit;
2502+ self
2503+ }
24972504}
24982505
24992506pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
25002507 let PassAlongPathArgs {
25012508 origin_node, expected_path, recv_value, payment_hash : our_payment_hash,
25022509 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 ,
25042511 } = args;
25052512
25062513 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>
25442551 assert_eq ! ( our_payment_secret, onion_fields. as_ref( ) . unwrap( ) . payment_secret) ;
25452552 } ,
25462553 }
2547- assert_eq ! ( * amount_msat, recv_value) ;
2554+ assert ! ( * amount_msat >= recv_value) ;
2555+ assert ! ( * amount_msat <= recv_value + overpay_limit) ;
25482556 assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. channel_id == via_channel_id. unwrap( ) ) ) ;
25492557 assert ! ( node. node. list_channels( ) . iter( ) . any( |details| details. user_channel_id == via_user_channel_id. unwrap( ) ) ) ;
25502558 assert ! ( claim_deadline. unwrap( ) > node. best_block_info( ) . 1 ) ;
0 commit comments