Skip to content

Commit da6b69e

Browse files
committed
f - roll our own Duration::saturating_add
1 parent 6ccd751 commit da6b69e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightning-invoice/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,9 @@ impl Invoice {
12081208
/// Returns whether the expiry time would pass at the given point in time.
12091209
/// `at_time` is the timestamp as a duration since the UNIX epoch.
12101210
pub fn would_expire(&self, at_time: Duration) -> bool {
1211-
self.duration_since_epoch().saturating_add(self.expiry_time()) < at_time
1211+
self.duration_since_epoch()
1212+
.checked_add(self.expiry_time())
1213+
.unwrap_or_else(|| Duration::new(u64::max_value(), 1_000_000_000 - 1)) < at_time
12121214
}
12131215

12141216
/// Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise

0 commit comments

Comments
 (0)