Skip to content

Allow setting a ChannelConfig for LSPS2 JIT channels#985

Open
IgnacioPorte wants to merge 1 commit into
lightningdevkit:mainfrom
IgnacioPorte:2026-07-lsps2-jit-channel-config
Open

Allow setting a ChannelConfig for LSPS2 JIT channels#985
IgnacioPorte wants to merge 1 commit into
lightningdevkit:mainfrom
IgnacioPorte:2026-07-lsps2-jit-channel-config

Conversation

@IgnacioPorte

Copy link
Copy Markdown

Hey this PR closes #961.

Context

When acting as an LSPS2 service, the LSP always reuse the node-wide configuration
for the JIT channels it opens towards clients, hard coding their forwarding fees
to zero. An LSP may however want different parameters on client channels than
on its public channels, e.g., different forwarding fees or a different
cltv_expiry_delta.

Changes

Adds an optional channel_config field to LSPS2ServiceConfig:

  • If set, the given ChannelConfig is applied as-is to newly-opened JIT
    channels. In particular, configured forwarding fees are charged in addition
    to the channel opening fee.
  • If unset (None), behavior is unchanged: we reuse the node-wide config but
    override the forwarding fees to zero, as we're already compensated via the
    channel opening fee.

Compatibility

This is a breaking change, existing LSPS2ServiceConfig initializers need to
provide the new field. I assumed this is acceptable based on the struct's
history.

Testing

Extended lsps2_client_service_integration to pass a custom config and assert
the opened JIT channel carries it.


This PR was developed with the assistance of AI tooling (Claude Code).

@ldk-reviews-bot

ldk-reviews-bot commented Jul 14, 2026

Copy link
Copy Markdown

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

@ldk-reviews-bot
ldk-reviews-bot requested a review from tnull July 14, 2026 22:35

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this. While I think it makes sense to let the LSP configure certain values, ChannelConfig also has a few fields that don't make sense / we don't want to override (notably forwarding fees, but also stuff like accept_underpaying_htlcs). So it's not the right type for this API. If anything we need to create an LSP-specific channel config variant.

Comment thread src/liquidity/service/lsps2.rs Outdated
/// If set, the given config is used without modification. Note that this means any
/// forwarding fees configured here are charged in addition to the channel opening fee.
///
/// If set to `None`, we'll reuse the node-wide config, but override the forwarding fees

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's odd to reuse the object, but then honor only a few fields of it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! Read through #478 and I see the problem with the forwarding fees now, the client builds the JIT invoice's route hints before the channel exists, so fees set only in the channel config would never be covered by the sender. Communicating them to the client would need protocol support that bLIP-52 doesn't have today.

I pushed a new version with a dedicated LSPS2ChannelConfig that only exposes cltv_expiry_delta, max_dust_htlc_exposure and force_close_avoidance_max_fee_satoshis. Fees stay at zero and accept_underpaying_htlcs is untouched. Let me know if that make sense.

When acting as an LSPS2 service, we'd previously always reuse the
node-wide configuration for the JIT channels we open towards clients.

Here, we add an optional channel_config field to LSPS2ServiceConfig
that allows configuring the JIT channels separately from regular
channels. As some ChannelConfig fields must not be overridden for JIT
channels (notably forwarding fees, which would need to be communicated
via the LSPS2 protocol to end up in invoice route hints, and
accept_underpaying_htlcs, which the service relies on to collect the
channel opening fee), we introduce a dedicated LSPS2ChannelConfig only
exposing the safe subset: cltv_expiry_delta, max_dust_htlc_exposure,
and force_close_avoidance_max_fee_satoshis. Unset fields fall back to
the node-wide config, and forwarding fees remain always zero.

This change was developed with the assistance of AI tooling (Claude Code).
@IgnacioPorte
IgnacioPorte force-pushed the 2026-07-lsps2-jit-channel-config branch from b94b182 to 21c5981 Compare July 17, 2026 03:59
@IgnacioPorte
IgnacioPorte requested a review from tnull July 17, 2026 04:12
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.

Allow configuring channel parameters based on whether the channel is an LSP client channel

3 participants