Skip to content

Commit a8755e1

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 8dca9ee commit a8755e1

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

282282
fn has_expired(params: &RouteParameters) -> bool {
283-
let expiry_time = Duration::from_secs(params.payee.expiry_time.unwrap());
284-
Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, expiry_time)
283+
if let Some(expiry_time) = params.payee.expiry_time {
284+
Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, Duration::from_secs(expiry_time))
285+
} else { false }
285286
}
286287

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

0 commit comments

Comments
 (0)