fix: advertise the plain invoice_expiration_window - #914
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughChangesThe Lightning info tags now report Lightning policy tag correction
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change corrects the advertised invoice expiration value while preserving tag names and ordering; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The kind-38385 info event filled the `invoice_expiration_window` tag from `hold_invoice_expiration_window`, a copy-paste from the tag two entries above. Those are independent settings, and the one a client needs to build an acceptable payout invoice was the one misreported: a client that trusted the info event got a cant-do back and the order sat in `waiting-buyer-invoice` until reaped. Extract the `ln_settings` tags into `ln_policy_tags`, mirroring the existing `bond_policy_tags`, and read the field each tag names. The extraction is what makes the regression test meaningful — the shared test settings leave both windows at `0`, so a test driven by the global config cannot tell the two fields apart. Wire order of the tags is unchanged. Document what separates the two windows on the settings fields themselves, where their doc comments only paraphrased their names. Closes MostroP2P#895
7d246be to
00d58c0
Compare
Catrya
left a comment
There was a problem hiding this comment.
The fix itself is right. Blocking on one doc comment this PR gets wrong.
hold_invoice_expiration_window: "Lifetime, in seconds, of the hold invoice
the seller pays" is false. After this PR nothing reads that setting except
the info tag itself: create_hold_invoice (src/lightning/mod.rs:150-156)
passes only cltv_expiry and leaves expiry at 0, so LND applies its
default of 86400s. The invoice lives 24h while we advertise 300s, the same
class of bug this PR is fixing on the sibling tag, now stated explicitly in a
doc comment instead of merely implied. Please document what's true and open a
follow-up for the real fix:
/// Advertised in the info event only, it is *not* applied to the hold
/// invoice, which is created without an `expiry` and so uses LND's
/// default (86400s). Distinct from `invoice_expiration_window`, which
/// governs the payout invoice. See #<follow-up>.
Two non-blocking notes while you're in there:
invoice_expiration_windowalso gates bond payout invoices
(src/app/bond/payout.rs:1391), and does not apply to LNURL /
Lightning-address destinations (src/lightning/invoice.rs:56-59), so
"a buyer payout invoice" is off in both directions.- No test asserts
info_to_tagsstill emits the block — drop the
extend(ln_policy_tags(...))line and the suite stays green.
|
Closing as superseded by #952, which landed the same fix on 2026-09-04. That PR corrects the tag the same way this one did and goes one better: Rebasing this onto Two things this PR raised that #952 does not cover, so they do not get lost:
Thanks for the review, @Catrya — the blocking point was correct and it is what led to #955. |
Closes #895.
The bug
The kind-38385 info event filled the
invoice_expiration_windowtag fromln_settings.hold_invoice_expiration_window— a copy-paste from the tag twoentries above, so both tags published the same number.
The two are independent settings: the hold invoice window is the lifetime of
the invoice the seller pays, while
invoice_expiration_windowis the minimumremaining lifetime a buyer payout invoice must have, enforced in
src/lightning/invoice.rs. So the one number a client needs in order to buildan acceptable payout invoice was precisely the one the daemon misreported. A
client that trusted the info event got a
cant-doback, and the order sat inwaiting-buyer-invoiceuntil it was reaped.The change
ln_settings-derived tags intoln_policy_tags, mirroringthe existing
bond_policy_tags. The helper is spliced in at the originalposition, so the wire order of the info event's tags is unchanged.
(
src/config/types.rs), where the doc comments only paraphrased the names.Why the extraction
Without it the regression test would be vacuous.
test_settings()buildsLightningSettings::default(), which leaves both windows at0, andMOSTRO_CONFIGis a process-wide OnceLock no test can mutate — so a testdriven through
info_to_tags()passes just as happily with the fields swapped.Testing the pure helper allows pinning each window against a distinct value.
This is the same reason
bond_policy_tagswas split out, and its doc commentsays so.
Verification
The regression test was confirmed to fail against the original bug before the
fix was applied:
With the fix, the full suite is green:
cargo clippy --all-targets --all-features -- -D warningsis clean andcargo fmthas been applied. No schema or config changes: the tag name and thesettings keys are untouched, only the value the tag is filled from. Clients
pick up the corrected value on the next info event.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests