10
10
//! Convenient utilities for paying Lightning invoices.
11
11
12
12
use crate :: Bolt11Invoice ;
13
- use crate :: prelude:: * ;
14
13
15
14
use bitcoin_hashes:: Hash ;
16
15
17
16
use lightning:: ln:: PaymentHash ;
18
17
use lightning:: ln:: channelmanager:: RecipientOnionFields ;
19
18
use lightning:: routing:: router:: { PaymentParameters , RouteParameters } ;
20
19
21
- use core:: time:: Duration ;
22
-
23
20
/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
24
21
/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
25
22
/// [`ChannelManager::send_preflight_probes`].
@@ -61,10 +58,6 @@ pub fn payment_parameters_from_invoice(invoice: &Bolt11Invoice)
61
58
}
62
59
}
63
60
64
- fn expiry_time_from_unix_epoch ( invoice : & Bolt11Invoice ) -> Duration {
65
- invoice. signed_invoice . raw_invoice . data . timestamp . 0 + invoice. expiry_time ( )
66
- }
67
-
68
61
fn params_from_invoice ( invoice : & Bolt11Invoice , amount_msat : u64 )
69
62
-> ( PaymentHash , RecipientOnionFields , RouteParameters ) {
70
63
let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
@@ -76,8 +69,10 @@ fn params_from_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
76
69
invoice. recover_payee_pub_key ( ) ,
77
70
invoice. min_final_cltv_expiry_delta ( ) as u32
78
71
)
79
- . with_expiry_time ( expiry_time_from_unix_epoch ( invoice) . as_secs ( ) )
80
72
. with_route_hints ( invoice. route_hints ( ) ) . unwrap ( ) ;
73
+ if let Some ( expiry) = invoice. expires_at ( ) {
74
+ payment_params = payment_params. with_expiry_time ( expiry. as_secs ( ) ) ;
75
+ }
81
76
if let Some ( features) = invoice. features ( ) {
82
77
payment_params = payment_params. with_bolt11_features ( features. clone ( ) ) . unwrap ( ) ;
83
78
}
0 commit comments