@@ -215,11 +215,12 @@ pub(crate) fn amt_to_forward_msat(inbound_amt_msat: u64, payment_relay: &Payment
215
215
}
216
216
217
217
pub ( 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
219
220
) -> Result < BlindedPayInfo , ( ) > {
220
221
let mut curr_base_fee: u64 = 0 ;
221
222
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 ;
223
224
for tlvs in intermediate_nodes. iter ( ) . rev ( ) . map ( |n| & n. tlvs ) {
224
225
// In the future, we'll want to take the intersection of all supported features for the
225
226
// `BlindedPayInfo`, but there are no features in that context right now.
@@ -292,6 +293,7 @@ mod tests {
292
293
use crate :: blinded_path:: payment:: { ForwardNode , ForwardTlvs , ReceiveTlvs , PaymentConstraints , PaymentRelay } ;
293
294
use crate :: ln:: PaymentSecret ;
294
295
use crate :: ln:: features:: BlindedHopFeatures ;
296
+ use crate :: ln:: functional_test_utils:: TEST_FINAL_CLTV ;
295
297
296
298
#[ test]
297
299
fn compute_payinfo ( ) {
@@ -339,10 +341,10 @@ mod tests {
339
341
} ,
340
342
} ;
341
343
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 ( ) ;
343
345
assert_eq ! ( blinded_payinfo. fee_base_msat, 201 ) ;
344
346
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 ) ;
346
348
assert_eq ! ( blinded_payinfo. htlc_minimum_msat, 900 ) ;
347
349
assert_eq ! ( blinded_payinfo. htlc_maximum_msat, htlc_maximum_msat) ;
348
350
}
@@ -356,10 +358,10 @@ mod tests {
356
358
htlc_minimum_msat : 1 ,
357
359
} ,
358
360
} ;
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 ( ) ;
360
362
assert_eq ! ( blinded_payinfo. fee_base_msat, 0 ) ;
361
363
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 ) ;
363
365
assert_eq ! ( blinded_payinfo. htlc_minimum_msat, 1 ) ;
364
366
assert_eq ! ( blinded_payinfo. htlc_maximum_msat, 4242 ) ;
365
367
}
@@ -410,7 +412,7 @@ mod tests {
410
412
} ,
411
413
} ;
412
414
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 ( ) ;
414
416
assert_eq ! ( blinded_payinfo. htlc_minimum_msat, 2_000 ) ;
415
417
}
416
418
@@ -460,10 +462,10 @@ mod tests {
460
462
} ,
461
463
} ;
462
464
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( ) ) ;
464
466
465
467
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 ( ) ;
467
469
assert_eq ! ( blinded_payinfo. htlc_minimum_msat, htlc_minimum_msat) ;
468
470
assert_eq ! ( blinded_payinfo. htlc_maximum_msat, htlc_maximum_msat) ;
469
471
}
@@ -514,7 +516,7 @@ mod tests {
514
516
} ,
515
517
} ;
516
518
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 ( ) ;
518
520
assert_eq ! ( blinded_payinfo. htlc_maximum_msat, 3997 ) ;
519
521
}
520
522
}
0 commit comments