]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Explain no-std Bolt11Invoice::duration_since_epoch
authorJeffrey Czyz <jkczyz@gmail.com>
Mon, 11 Nov 2024 22:43:53 +0000 (16:43 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 12 Nov 2024 18:24:52 +0000 (12:24 -0600)
lightning/src/ln/channelmanager.rs

index 5a20c8e24449c7206f24a5820a828220234c9b7a..61c5958ac6c944957ff5c73849fe7a5e39e80d9d 100644 (file)
@@ -9268,6 +9268,10 @@ where
                        SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)
                                .expect("SystemTime::now() should be after SystemTime::UNIX_EPOCH")
                };
+
+               // This may be up to 2 hours in the future because of bitcoin's block time rule or about
+               // 10-30 minutes in the past if a block hasn't been found recently. This should be fine as
+               // the default invoice expiration is 2 hours, though shorter expirations may be problematic.
                #[cfg(not(feature = "std"))]
                let duration_since_epoch =
                        Duration::from_secs(self.highest_seen_timestamp.load(Ordering::Acquire) as u64);