Skip to content

Commit 2a857f1

Browse files
committed
Use constant for invoice's default expiry value
1 parent 7af9976 commit 2a857f1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lightning-invoice/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ const SYSTEM_TIME_MAX_UNIX_TIMESTAMP: u64 = std::i32::MAX as u64;
5454
/// it should be rather low as long as we still have to support 32bit time representations
5555
const MAX_EXPIRY_TIME: u64 = 60 * 60 * 24 * 356;
5656

57+
/// Default expiry time as defined by [BOLT 11].
58+
///
59+
/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
60+
const DEFAULT_EXPIRY_TIME: u64 = 3600;
61+
5762
/// This function is used as a static assert for the size of `SystemTime`. If the crate fails to
5863
/// compile due to it this indicates that your system uses unexpected bounds for `SystemTime`. You
5964
/// can remove this functions and run the test `test_system_time_bounds_assumptions`. In any case,
@@ -1021,11 +1026,11 @@ impl Invoice {
10211026
self.signed_invoice.recover_payee_pub_key().expect("was checked by constructor").0
10221027
}
10231028

1024-
/// Returns the invoice's expiry time if present
1029+
/// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
10251030
pub fn expiry_time(&self) -> Duration {
10261031
self.signed_invoice.expiry_time()
10271032
.map(|x| x.0)
1028-
.unwrap_or(Duration::from_secs(3600))
1033+
.unwrap_or(Duration::from_secs(DEFAULT_EXPIRY_TIME))
10291034
}
10301035

10311036
/// Returns the invoice's `min_cltv_expiry` time if present

0 commit comments

Comments
 (0)