From e9e8a7d58d3fd415ad1746b3fee5f332c78d72e9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 27 Oct 2021 22:12:07 +0000 Subject: [PATCH] Dont unwrap `RouteParameter::expiry_time` as users can set it Users can provide anything they want as `RouteParameters` so we shouldn't assume any fields are set any particular way, including `expiry_time` set at all. --- lightning-invoice/src/payment.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index 68b06faa0..b706deadd 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -313,8 +313,9 @@ fn expiry_time_from_unix_epoch(invoice: &Invoice) -> Duration { } fn has_expired(params: &RouteParameters) -> bool { - let expiry_time = Duration::from_secs(params.payee.expiry_time.unwrap()); - Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, expiry_time) + if let Some(expiry_time) = params.payee.expiry_time { + Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, Duration::from_secs(expiry_time)) + } else { false } } impl EventHandler for InvoicePayer -- 2.39.5