Skip to content

Commit 06b6016

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 576394b commit 06b6016

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
@@ -301,8 +301,9 @@ fn expiry_time_from_unix_epoch(invoice: &Invoice) -> Duration {
301301
}
302302

303303
fn has_expired(params: &RouteParameters) -> bool {
304-
let expiry_time = Duration::from_secs(params.payee.expiry_time.unwrap());
305-
Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, expiry_time)
304+
if let Some(expiry_time) = params.payee.expiry_time {
305+
Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, Duration::from_secs(expiry_time))
306+
} else { false }
306307
}
307308

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

0 commit comments

Comments
 (0)