@@ -2731,6 +2731,7 @@ pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
27312731 pub expected_min_htlc_overpay : Vec < u32 > ,
27322732 pub skip_last : bool ,
27332733 pub payment_preimage : PaymentPreimage ,
2734+ pub custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ,
27342735 // Allow forwarding nodes to have taken 1 msat more fee than expected based on the downstream
27352736 // fulfill amount.
27362737 //
@@ -2749,7 +2750,7 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
27492750 Self {
27502751 origin_node, expected_paths, expected_extra_fees : vec ! [ 0 ; expected_paths. len( ) ] ,
27512752 expected_min_htlc_overpay : vec ! [ 0 ; expected_paths. len( ) ] , skip_last : false , payment_preimage,
2752- allow_1_msat_fee_overpay : false ,
2753+ allow_1_msat_fee_overpay : false , custom_tlvs : vec ! [ ] ,
27532754 }
27542755 }
27552756 pub fn skip_last ( mut self , skip_last : bool ) -> Self {
@@ -2768,12 +2769,16 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
27682769 self . allow_1_msat_fee_overpay = true ;
27692770 self
27702771 }
2772+ pub fn with_custom_tlvs ( mut self , custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ) -> Self {
2773+ self . custom_tlvs = custom_tlvs;
2774+ self
2775+ }
27712776}
27722777
2773- pub fn pass_claimed_payment_along_route < ' a , ' b , ' c , ' d > ( args : ClaimAlongRouteArgs ) -> u64 {
2778+ pub fn pass_claimed_payment_along_route ( args : ClaimAlongRouteArgs ) -> u64 {
27742779 let ClaimAlongRouteArgs {
27752780 origin_node, expected_paths, expected_extra_fees, expected_min_htlc_overpay, skip_last,
2776- payment_preimage : our_payment_preimage, allow_1_msat_fee_overpay,
2781+ payment_preimage : our_payment_preimage, allow_1_msat_fee_overpay, custom_tlvs ,
27772782 } = args;
27782783 let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
27792784 assert_eq ! ( claim_event. len( ) , 1 ) ;
@@ -2787,11 +2792,13 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27872792 | PaymentPurpose :: Bolt12RefundPayment { payment_preimage : Some ( preimage) , .. } ,
27882793 amount_msat,
27892794 ref htlcs,
2795+ ref onion_fields,
27902796 ..
27912797 } => {
27922798 assert_eq ! ( preimage, our_payment_preimage) ;
27932799 assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
27942800 assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2801+ assert_eq ! ( onion_fields. as_ref( ) . unwrap( ) . custom_tlvs, custom_tlvs) ;
27952802 expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
27962803 fwd_amt_msat = amount_msat;
27972804 } ,
@@ -2802,11 +2809,13 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
28022809 payment_hash,
28032810 amount_msat,
28042811 ref htlcs,
2812+ ref onion_fields,
28052813 ..
28062814 } => {
28072815 assert_eq ! ( & payment_hash. 0 , & Sha256 :: hash( & our_payment_preimage. 0 ) [ ..] ) ;
28082816 assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
28092817 assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2818+ assert_eq ! ( onion_fields. as_ref( ) . unwrap( ) . custom_tlvs, custom_tlvs) ;
28102819 expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
28112820 fwd_amt_msat = amount_msat;
28122821 }
0 commit comments