Skip to content

Commit 8da30df

Browse files
authored
Merge pull request #3405 from jkczyz/2024-11-bolt11-invoice-utils-follow-up
2 parents 1c5b4c1 + 20ef217 commit 8da30df

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lightning/src/ln/channelmanager.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -9298,8 +9298,12 @@ where
92989298
let duration_since_epoch = {
92999299
use std::time::SystemTime;
93009300
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)
9301-
.expect("for the foreseeable future this shouldn't happen")
9301+
.expect("SystemTime::now() should be after SystemTime::UNIX_EPOCH")
93029302
};
9303+
9304+
// This may be up to 2 hours in the future because of bitcoin's block time rule or about
9305+
// 10-30 minutes in the past if a block hasn't been found recently. This should be fine as
9306+
// the default invoice expiration is 2 hours, though shorter expirations may be problematic.
93039307
#[cfg(not(feature = "std"))]
93049308
let duration_since_epoch =
93059309
Duration::from_secs(self.highest_seen_timestamp.load(Ordering::Acquire) as u64);
@@ -9388,7 +9392,8 @@ pub struct Bolt11InvoiceParameters {
93889392
/// [`DEFAULT_EXPIRY_TIME`] by default.
93899393
///
93909394
/// The creation time used is the duration since the Unix epoch for `std` builds. For non-`std`
9391-
/// builds, the highest block timestamp seen is used instead.
9395+
/// builds, the highest block timestamp seen is used instead. In the latter case, use a long
9396+
/// enough expiry to account for the average block time.
93929397
pub invoice_expiry_delta_secs: Option<u32>,
93939398

93949399
/// The minimum `cltv_expiry` for the last HTLC in the route. If not set, will use

0 commit comments

Comments
 (0)