Skip to content

Commit 22305a9

Browse files
committed
Drop old expiry_time_from_unix_epoch helper in expiry time lookup
Since there's a much simpler way to go about it with `Bolt11Invoice::expires_at`.
1 parent a6039b9 commit 22305a9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lightning-invoice/src/payment.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
//! Convenient utilities for paying Lightning invoices.
1111
1212
use crate::Bolt11Invoice;
13-
use crate::prelude::*;
1413

1514
use bitcoin_hashes::Hash;
1615

1716
use lightning::ln::PaymentHash;
1817
use lightning::ln::channelmanager::RecipientOnionFields;
1918
use lightning::routing::router::{PaymentParameters, RouteParameters};
2019

21-
use core::time::Duration;
22-
2320
/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount
2421
/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or
2522
/// [`ChannelManager::send_preflight_probes`].
@@ -61,10 +58,6 @@ pub fn payment_parameters_from_invoice(invoice: &Bolt11Invoice)
6158
}
6259
}
6360

64-
fn expiry_time_from_unix_epoch(invoice: &Bolt11Invoice) -> Duration {
65-
invoice.signed_invoice.raw_invoice.data.timestamp.0 + invoice.expiry_time()
66-
}
67-
6861
fn params_from_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
6962
-> (PaymentHash, RecipientOnionFields, RouteParameters) {
7063
let payment_hash = PaymentHash((*invoice.payment_hash()).into_inner());
@@ -76,8 +69,10 @@ fn params_from_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
7669
invoice.recover_payee_pub_key(),
7770
invoice.min_final_cltv_expiry_delta() as u32
7871
)
79-
.with_expiry_time(expiry_time_from_unix_epoch(invoice).as_secs())
8072
.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+
}
8176
if let Some(features) = invoice.features() {
8277
payment_params = payment_params.with_bolt11_features(features.clone()).unwrap();
8378
}

0 commit comments

Comments
 (0)