File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,15 @@ mod sync;
85
85
86
86
pub use de:: { ParseError , ParseOrSemanticError } ;
87
87
88
+ /// The number of bits used to represent timestamps as defined in BOLT 11.
89
+ const TIMESTAMP_BITS : usize = 35 ;
90
+
88
91
/// The maximum timestamp that can be represented as a [`Duration`] since the UNIX epoch while
89
92
/// allowing for adding an expiry without overflowing.
90
- const MAX_TIMESTAMP : u64 = core:: i64 :: MAX as u64 ;
93
+ const MAX_TIMESTAMP : u64 = core:: u64 :: MAX >> ( 64 - TIMESTAMP_BITS ) ;
91
94
92
95
/// The maximum expiry allowed, represented as a [`Duration`] since the invoice timestamp.
93
- const MAX_EXPIRY_TIME : u64 = ( core:: i64 :: MAX ) as u64 + 1 ;
96
+ const MAX_EXPIRY_TIME : u64 = core:: u64 :: MAX - MAX_TIMESTAMP ;
94
97
95
98
/// Assert that the maximum expiry represented as a [`Duration`] since the UNIX epoch does not
96
99
/// exceed [`u64::MAX`].
You can’t perform that action at this time.
0 commit comments