Skip to content

Fix StaticInvoice::is_offer_expired to check the offer's expiry#4594

Open
tnull wants to merge 1 commit intolightningdevkit:mainfrom
tnull:2026-05-static-invoice-is-offer-expired
Open

Fix StaticInvoice::is_offer_expired to check the offer's expiry#4594
tnull wants to merge 1 commit intolightningdevkit:mainfrom
tnull:2026-05-static-invoice-is-offer-expired

Conversation

@tnull
Copy link
Copy Markdown
Contributor

@tnull tnull commented May 5, 2026

The std-only StaticInvoice::is_offer_expired accessor delegated to InvoiceContents::is_expired, which compares created_at + relative_expiry against the current time — that is the invoice's expiry, not the offer's. The _no_std sibling and flow.rs:: enqueue_static_invoice already treat the two as distinct checks.

A payer or forwarder using the std API to decide whether to honor a static invoice would therefore get the wrong answer in either direction: forwarding offers the issuer has already retired (when the invoice is still fresh), or refusing offers that are still valid (when the invoice has aged past its relative_expiry but the offer itself has no absolute_expiry).

Route the std accessor through InvoiceContents::is_offer_expired so both the std and no-std paths consult the offer's expiry.

Co-Authored-By: HAL 9000

The std-only `StaticInvoice::is_offer_expired` accessor delegated to
`InvoiceContents::is_expired`, which compares `created_at +
relative_expiry` against the current time — that is the *invoice*'s
expiry, not the offer's. The `_no_std` sibling and `flow.rs::
enqueue_static_invoice` already treat the two as distinct checks.

A payer or forwarder using the std API to decide whether to honor a
static invoice would therefore get the wrong answer in either
direction: forwarding offers the issuer has already retired (when the
invoice is still fresh), or refusing offers that are still valid (when
the invoice has aged past its `relative_expiry` but the offer itself
has no `absolute_expiry`).

Route the std accessor through `InvoiceContents::is_offer_expired` so
both the std and no-std paths consult the offer's expiry.

Co-Authored-By: HAL 9000
@tnull tnull requested a review from valentinewallace May 5, 2026 18:59
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented May 5, 2026

👋 Thanks for assigning @valentinewallace as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-claude-review-bot
Copy link
Copy Markdown
Collaborator

No remaining misuse of is_expired() where is_offer_expired() was intended. The fix is clean and complete.

No issues found.

@ldk-reviews-bot
Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.24%. Comparing base (1a26867) to head (c005b11).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4594      +/-   ##
==========================================
- Coverage   86.84%   86.24%   -0.60%     
==========================================
  Files         161      159       -2     
  Lines      109260   109196      -64     
  Branches   109260   109196      -64     
==========================================
- Hits        94882    94177     -705     
- Misses      11797    12408     +611     
- Partials     2581     2611      +30     
Flag Coverage Δ
fuzzing-fake-hashes ?
fuzzing-real-hashes ?
tests 86.24% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants