Skip to content

Commit e9e8a7d

Browse files
committed
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.
1 parent 51dd344 commit e9e8a7d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lightning-invoice/src/payment.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ fn expiry_time_from_unix_epoch(invoice: &Invoice) -> Duration {
313313
}
314314

315315
fn has_expired(params: &RouteParameters) -> bool {
316-
let expiry_time = Duration::from_secs(params.payee.expiry_time.unwrap());
317-
Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, expiry_time)
316+
if let Some(expiry_time) = params.payee.expiry_time {
317+
Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, Duration::from_secs(expiry_time))
318+
} else { false }
318319
}
319320

320321
impl<P: Deref, R, S: Deref, L: Deref, E> EventHandler for InvoicePayer<P, R, S, L, E>

0 commit comments

Comments
 (0)