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
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