Skip to content

Batch JIT channel opens via batch_funding_transaction_generated to lower the minimum economical channel #249

Description

@ConorOkus

Support batched JIT channel funding in the LSPS2 service

Motivation

We're running LDK Server's experimental LSPS2 service (#52) as an LSP backend, with an operator-policy layer on top. bLIP-52 / LSPS2 explicitly anticipates batching multiple JIT channel opens into a single funding transaction, and since on-chain fees dominate the cost of small JIT opens, batching is the main lever for lowering the minimum economical channel size an LSP can offer.

Current behavior

LDK Server / ldk-node funds one channel per transaction: on FundingGenerationReady, a single funding tx is built from the internal wallet and funding_transaction_generated is called. ChannelManager::batch_funding_transaction_generated exists in rust-lightning but is never surfaced, and the event handler isn't pluggable — so batching can't be layered on from outside without a fork.

Interaction with the LSPS2 trust model

The bound on any batching/accumulation window depends on client_trusts_lsp (see also the client-trusts-LSP flow discussion in ldk-node#479), and this shapes the API that would be needed:

  • client_trusts_lsp=true (our deployment): broadcast can be deferred until after clients claim, so the accumulation window is not bounded by settlement latency. However, batch composition freezes at the first preimage release: clients release preimages against zero-conf commitment transactions spending a specific funding outpoint, and rebuilding the batch tx would change the txid and invalidate outpoints that clients have already settled against. Nothing in LSPS2 supports re-negotiating funding with a client who has already given up a preimage. So: broadcast is deferrable, but eviction/rebuild only applies before any member settles.
  • client_trusts_lsp=false (spec default): the funding tx must be broadcast before asking any client to release a preimage, so the window is additionally bounded by the first payment that needs to settle.
  • Mixed batches: a single client_trusts_lsp=false member collapses the whole batch's window back to that member's settlement time, so the policy layer should segregate batches by trust mode.

Upstream API gap: batch_funding_transaction_generated, like its single-channel sibling, hands the tx to ChannelManager for broadcast once counterparty signatures arrive. The client_trusts_lsp=true flow needs a manual-broadcast variant — the batch analogue of unsafe_manual_funding_transaction_generated / FundingTxBroadcastSafe, which the single-channel LSPS2 service path already uses. As far as we can tell no batch equivalent exists, so this is really two pieces of work: surfacing batching in ldk-node / LDK Server, and a batch manual-broadcast API upstream in rust-lightning.

Other constraints we're aware of

  • LDK's batch funding API currently covers V1 opens only (no dual-funded/V2), and a batched V1 funding tx isn't RBF-able. Batch size is therefore a risk/latency knob as much as a fee knob.
  • Non-RBF + deliberately deferred broadcast means the feerate chosen at build time can be stale at broadcast time. The batch tx should always carry an LSP change output so CPFP is available, and a max-deferral deadline should force broadcast before the estimate degrades too far.
  • While broadcast is withheld, the funding inputs must be reserved so the LSP's own wallet can't accidentally double-spend them, and claimed-but-unbroadcast channels should count against the zero-conf exposure limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions