From: Matt Corallo Date: Wed, 27 Oct 2021 22:12:07 +0000 (+0000) Subject: Dont unwrap `RouteParameter::expiry_time` as users can set it X-Git-Tag: v0.0.103~4^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e9e8a7d58d3fd415ad1746b3fee5f332c78d72e9;p=rust-lightning 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. --- 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