Skip to content

Move BOLT11 JIT params to payment metadata#899

Open
tnull wants to merge 3 commits intolightningdevkit:mainfrom
tnull:2026-05-move-jit-params-to-payment-metadata
Open

Move BOLT11 JIT params to payment metadata#899
tnull wants to merge 3 commits intolightningdevkit:mainfrom
tnull:2026-05-move-jit-params-to-payment-metadata

Conversation

@tnull
Copy link
Copy Markdown
Collaborator

@tnull tnull commented May 6, 2026

Context

We recently found that for the intended BOLT12-JIT flow we'll have to encode the LSPS2 parameters in the payment metadata (based on lightningdevkit/rust-lightning#4584). As a prefactor to that (and to simplify things for #811, rather than add yet another store type there, just to revert once we get to the BOLT12-JIT changes), we here switch to store the LSPS2 parameters in the BOLT11 payment_metadata rather than persisting them on-disk. To make this safe we'll also need lightningdevkit/rust-lightning#4528, as otherwise the payer could collude with the LSP to rob the payee.

Summary

This moves LSPS2/JIT-channel receive parameters out of dedicated payment-store
state and into the BOLT11 invoice payment_metadata, so the payment store no
longer needs a PaymentKind::Bolt11Jit variant for new payments.

Changes

  • Rename LSPFeeLimits to LSPS2Parameters.
  • Add Bolt11PaymentMetadata in bolt11.rs with TLV-based encoding.
  • Encode LSPS2Parameters into BOLT11 payment_metadata when creating JIT
    invoices.
  • Store new JIT receives as PaymentKind::Bolt11.
  • Decode legacy PaymentKind::Bolt11Jit records as PaymentKind::Bolt11.
  • Reject skimmed inbound payments unless valid BOLT11 payment_metadata proves
    the LSPS2 fee is within the negotiated limit.
  • Drop the stale top-level PaymentDetails field-1 JIT metadata reader, while
    keeping the released legacy PaymentKind::Bolt11Jit decoder.
  • Add a changelog note that pending JIT payments may fail after upgrade because
    prior JIT state is not migrated.

tnull added 3 commits May 6, 2026 13:46
The values describe the `LSPS2` parameters negotiated for JIT-channel
receives, not a fee-limit concept owned by the payment store.

Rename the public type and internal references while preserving the
existing fields, TLV encoding, and `PaymentKind::Bolt11Jit` storage
shape for the follow-up refactor.

Co-Authored-By: HAL 9000
`LSPS2Parameters` should travel with generated JIT invoices and the
returned recipient onion metadata instead of living in a dedicated
`PaymentKind::Bolt11Jit` payment-store variant.

Store new JIT payments as `PaymentKind::Bolt11`, decode legacy
`PaymentKind::Bolt11Jit` records as `PaymentKind::Bolt11`, and reject
nonzero `counterparty_skimmed_fee_msat` unless valid BOLT11
`payment_metadata` proves the `LSPS2` fee is allowed.

Co-Authored-By: HAL 9000
`PaymentDetails` field 1 only carried `LSPS2Parameters` in an unreleased
intermediate layout before JIT data moved into `PaymentKind::Bolt11Jit`.

Drop the stale reader path and compatibility fixture while keeping the
released legacy `PaymentKind::Bolt11Jit` decoder intact.

Co-Authored-By: HAL 9000
@tnull tnull requested a review from joostjager May 6, 2026 12:09
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented May 6, 2026

👋 Thanks for assigning @joostjager 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.

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.

2 participants