Skip to content

Commit 3c37984

Browse files
committed
f - check offer expiry
1 parent a57e77f commit 3c37984

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ impl<'a> InvoiceRequestBuilder<'a> {
140140
/// Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed
141141
/// by [`UnsignedInvoiceRequest::sign`].
142142
pub fn build(mut self) -> Result<UnsignedInvoiceRequest<'a>, SemanticError> {
143+
#[cfg(feature = "std")] {
144+
if self.offer.is_expired() {
145+
return Err(SemanticError::AlreadyExpired);
146+
}
147+
}
148+
143149
let chain = self.invoice_request.chain();
144150
if !self.offer.supports_chain(chain) {
145151
return Err(SemanticError::UnsupportedChain);

lightning/src/offers/parse.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ pub enum ParseError {
123123
/// Error when interpreting a TLV stream as a specific type.
124124
#[derive(Debug, PartialEq)]
125125
pub enum SemanticError {
126+
/// The current [`std::time::SystemTime`] is past the offer or invoice's expiration.
127+
AlreadyExpired,
126128
/// The provided chain hash does not correspond to a supported chain.
127129
UnsupportedChain,
128130
/// An amount was expected but was missing.

0 commit comments

Comments
 (0)