Skip to content

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

Merged
tnull merged 1 commit into
lightningdevkit:mainfrom
tnull:2026-05-static-invoice-is-offer-expired
May 6, 2026
Merged

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

Conversation

@tnull

@tnull tnull commented May 5, 2026

Copy link
Copy Markdown
Contributor

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

ldk-reviews-bot commented May 5, 2026

Copy link
Copy Markdown

👋 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

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

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.

@tnull

tnull commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

Going ahead landing this.

@tnull tnull merged commit 03ab73d into lightningdevkit:main May 6, 2026
23 of 25 checks passed
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

This method was added in 0.2 so no need to backport to 0.1.

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Backported to 0.2 in #4683.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants