@@ -253,6 +253,10 @@ where
253
253
) -> Result < PaymentId , PaymentError > {
254
254
debug_assert ! ( invoice. amount_milli_satoshis( ) . is_some( ) ^ amount_msats. is_some( ) ) ;
255
255
let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
256
+ if invoice. is_expired ( ) {
257
+ log_trace ! ( self . logger, "Invoice expired prior to first send for payment {}" , log_bytes!( payment_hash. 0 ) ) ;
258
+ return Err ( PaymentError :: Invoice ( "Invoice expired prior to send" ) ) ;
259
+ }
256
260
let retry_data_payment_id = loop {
257
261
let mut payment_cache = self . payment_cache . lock ( ) . unwrap ( ) ;
258
262
match payment_cache. entry ( payment_hash) {
@@ -269,10 +273,6 @@ where
269
273
final_value_msat : invoice. amount_milli_satoshis ( ) . or ( amount_msats) . unwrap ( ) ,
270
274
final_cltv_expiry_delta : invoice. min_final_cltv_expiry ( ) as u32 ,
271
275
} ;
272
- if has_expired ( & params) {
273
- log_trace ! ( self . logger, "Invoice expired prior to first send for payment {}" , log_bytes!( payment_hash. 0 ) ) ;
274
- return Err ( PaymentError :: Invoice ( "Invoice expired prior to send" ) ) ;
275
- }
276
276
let first_hops = self . payer . first_hops ( ) ;
277
277
let route = self . router . find_route (
278
278
& payer,
@@ -752,7 +752,6 @@ mod tests {
752
752
let payment_preimage = PaymentPreimage ( [ 1 ; 32 ] ) ;
753
753
let invoice = invoice ( payment_preimage) ;
754
754
let payment_id = Some ( invoice_payer. pay_invoice ( & invoice) . unwrap ( ) ) ;
755
- std:: thread:: sleep ( Duration :: from_secs ( 4 ) ) ;
756
755
assert_eq ! ( * payer. attempts. borrow( ) , 1 ) ;
757
756
758
757
let mut retry_data = TestRouter :: retry_for_invoice ( & invoice) ;
0 commit comments