-
Notifications
You must be signed in to change notification settings - Fork 421
Support invoice expiry over a year #1273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support invoice expiry over a year #1273
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1273 +/- ##
==========================================
+ Coverage 90.40% 90.72% +0.31%
==========================================
Files 70 71 +1
Lines 38118 39381 +1263
==========================================
+ Hits 34462 35728 +1266
+ Misses 3656 3653 -3
Continue to review full report at Codecov.
|
lightning-invoice/src/lib.rs
Outdated
| /// Allow the expiry time to be up to one year. Since this reduces the range of possible timestamps | ||
| /// it should be rather low as long as we still have to support 32bit time representations | ||
| const MAX_EXPIRY_TIME: u64 = 60 * 60 * 24 * 356; | ||
| /// The maximum expiry allowed, represented as a [`Duration`] since the invoice timestamp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have a max expiry at all? Can we just update the expiry-check logic to do a saturating add?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
62235d4 to
5f61a12
Compare
|
I assume the serialization of |
da6b69e to
6002032
Compare
Discussed offline. BOLT 11 defines timestamps as 35 bits, so updated the PR yesterday to enforce this instead. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM, feel free to squash.
lightning-invoice/src/lib.rs
Outdated
| Ok(t) => self.tagged_fields.push(TaggedField::ExpiryTime(t)), | ||
| Err(e) => self.error = Some(e), | ||
| }; | ||
| self.tagged_fields.push(TaggedField::ExpiryTime(ExpiryTime::from_duration(expiry_time))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: when you squash, can you make this a tab not space (it was already spaces before).
lightning-invoice/src/lib.rs
Outdated
| /// Create a new `PositiveTimestamp` from a unix timestamp in the Range | ||
| /// `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a | ||
| /// `CreationError::TimestampOutOfBounds`. | ||
| /// Creates a `PositiveTimestamp` from a unix timestamp in the range `0...MAX_TIMESTAMP`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're gonna reference MAX_TIMESTAMP in the docs it should be pub.
The lightning-invoice crate represents timestamps as Duration since the UNIX epoch rather than a SystemTime. Therefore, internal calculations are in terms of u64-based Durations. This allows for relaxing the one year maximum expiry.
cdf670c to
3b14a76
Compare
TheBlueMatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3b14a76
|
ACK |
The lightning-invoice crate represents timestamps as
Durationsince the UNIX epoch rather than aSystemTime. Therefore, internal calculations are in terms ofu64-basedDurations. This allows for relaxing the one year maximum expiry.Fixes #1235