@@ -215,11 +215,12 @@ pub(crate) fn amt_to_forward_msat(inbound_amt_msat: u64, payment_relay: &Payment
215215}
216216
217217pub ( super ) fn compute_payinfo (
218- intermediate_nodes : & [ ForwardNode ] , payee_tlvs : & ReceiveTlvs , payee_htlc_maximum_msat : u64
218+ intermediate_nodes : & [ ForwardNode ] , payee_tlvs : & ReceiveTlvs , payee_htlc_maximum_msat : u64 ,
219+ min_final_cltv_expiry_delta : u16
219220) -> Result < BlindedPayInfo , ( ) > {
220221 let mut curr_base_fee: u64 = 0 ;
221222 let mut curr_prop_mil: u64 = 0 ;
222- let mut cltv_expiry_delta: u16 = 0 ;
223+ let mut cltv_expiry_delta: u16 = min_final_cltv_expiry_delta ;
223224 for tlvs in intermediate_nodes. iter ( ) . rev ( ) . map ( |n| & n. tlvs ) {
224225 // In the future, we'll want to take the intersection of all supported features for the
225226 // `BlindedPayInfo`, but there are no features in that context right now.
@@ -292,6 +293,7 @@ mod tests {
292293 use crate :: blinded_path:: payment:: { ForwardNode , ForwardTlvs , ReceiveTlvs , PaymentConstraints , PaymentRelay } ;
293294 use crate :: ln:: PaymentSecret ;
294295 use crate :: ln:: features:: BlindedHopFeatures ;
296+ use crate :: ln:: functional_test_utils:: TEST_FINAL_CLTV ;
295297
296298 #[ test]
297299 fn compute_payinfo ( ) {
@@ -339,10 +341,10 @@ mod tests {
339341 } ,
340342 } ;
341343 let htlc_maximum_msat = 100_000 ;
342- let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat) . unwrap ( ) ;
344+ let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat, 12 ) . unwrap ( ) ;
343345 assert_eq ! ( blinded_payinfo. fee_base_msat, 201 ) ;
344346 assert_eq ! ( blinded_payinfo. fee_proportional_millionths, 1001 ) ;
345- assert_eq ! ( blinded_payinfo. cltv_expiry_delta, 288 ) ;
347+ assert_eq ! ( blinded_payinfo. cltv_expiry_delta, 300 ) ;
346348 assert_eq ! ( blinded_payinfo. htlc_minimum_msat, 900 ) ;
347349 assert_eq ! ( blinded_payinfo. htlc_maximum_msat, htlc_maximum_msat) ;
348350 }
@@ -356,10 +358,10 @@ mod tests {
356358 htlc_minimum_msat : 1 ,
357359 } ,
358360 } ;
359- let blinded_payinfo = super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 ) . unwrap ( ) ;
361+ let blinded_payinfo = super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
360362 assert_eq ! ( blinded_payinfo. fee_base_msat, 0 ) ;
361363 assert_eq ! ( blinded_payinfo. fee_proportional_millionths, 0 ) ;
362- assert_eq ! ( blinded_payinfo. cltv_expiry_delta, 0 ) ;
364+ assert_eq ! ( blinded_payinfo. cltv_expiry_delta, TEST_FINAL_CLTV as u16 ) ;
363365 assert_eq ! ( blinded_payinfo. htlc_minimum_msat, 1 ) ;
364366 assert_eq ! ( blinded_payinfo. htlc_maximum_msat, 4242 ) ;
365367 }
@@ -410,7 +412,7 @@ mod tests {
410412 } ,
411413 } ;
412414 let htlc_maximum_msat = 100_000 ;
413- let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat) . unwrap ( ) ;
415+ let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat, TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
414416 assert_eq ! ( blinded_payinfo. htlc_minimum_msat, 2_000 ) ;
415417 }
416418
@@ -460,10 +462,10 @@ mod tests {
460462 } ,
461463 } ;
462464 let htlc_minimum_msat = 3798 ;
463- assert ! ( super :: compute_payinfo( & intermediate_nodes[ ..] , & recv_tlvs, htlc_minimum_msat - 1 ) . is_err( ) ) ;
465+ assert ! ( super :: compute_payinfo( & intermediate_nodes[ ..] , & recv_tlvs, htlc_minimum_msat - 1 , TEST_FINAL_CLTV as u16 ) . is_err( ) ) ;
464466
465467 let htlc_maximum_msat = htlc_minimum_msat + 1 ;
466- let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat) . unwrap ( ) ;
468+ let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat, TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
467469 assert_eq ! ( blinded_payinfo. htlc_minimum_msat, htlc_minimum_msat) ;
468470 assert_eq ! ( blinded_payinfo. htlc_maximum_msat, htlc_maximum_msat) ;
469471 }
@@ -514,7 +516,7 @@ mod tests {
514516 } ,
515517 } ;
516518
517- let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, 10_000 ) . unwrap ( ) ;
519+ let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, 10_000 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
518520 assert_eq ! ( blinded_payinfo. htlc_maximum_msat, 3997 ) ;
519521 }
520522}
0 commit comments