Skip to content

Forward channel closures and failed opens to the LSPS2 service - #1233

Open
tnull wants to merge 2 commits into
lightningdevkit:mainfrom
tnull:2026-11-lsps2-forward-channel-closed
Open

tnull wants to merge 2 commits into
lightningdevkit:mainfrom
tnull:2026-11-lsps2-forward-channel-closed

Conversation

@tnull

@tnull tnull commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

lightning-liquidity expects LSPS2 services to forward Event::ChannelClosed
and to report failed JIT channel opens. We did neither:

  • Closed JIT channels were never pruned, so the service kept (and persisted)
    the state of every client that ever paid for a channel. That state also
    counts towards the service's global peer limit.
  • If a JIT channel open failed, the intercepted HTLCs were held until they
    timed out, and the JIT state stayed stuck waiting for the channel, so
    retrying the same invoice could never trigger another open.

This PR fixes both, one commit each:

  1. Forward ChannelClosed to LSPS2ServiceHandler::channel_closed.
  2. Call LSPS2ServiceHandler::channel_open_failed when we can't open the
    channel (peer not connected, insufficient on-chain funds, create_channel
    failing) and when the channel closes before becoming ready. The held HTLCs
    are failed back right away and the payer can retry.

`lightning-liquidity` requires `Event::ChannelClosed` to be forwarded
to the LSPS2 service handler, which we never did. The service hence
kept the state of every JIT channel that ever got paid for, and with
it the persisted state of the respective client, forever. That state
also counts towards the service's global peer limit.

We now hand closed channels to the LSPS2 service, allowing it to prune
the state of JIT channels that are gone.

Co-Authored-By: HAL 9000
When we couldn't open a JIT channel as an LSPS2 service, or when the
channel closed before becoming ready, we never told
`lightning-liquidity` about it. The intercepted HTLCs were therefore
held until they timed out, and as the JIT channel state stayed stuck
waiting for the channel, no later payment to the same invoice could
trigger another attempt.

We now report failed channel opens to the LSPS2 service, which fails
the held HTLCs back right away and lets the payer retry.

Co-Authored-By: HAL 9000
@tnull tnull added this to the 0.8 milestone Nov 12, 2026
@tnull
tnull requested a review from jkczyz November 12, 2026 08:49
@ldk-reviews-bot

ldk-reviews-bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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

@tnull
tnull force-pushed the 2026-11-lsps2-forward-channel-closed branch from 049f1a4 to 3a3dafb Compare November 12, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants