Skip to content

Configure dust exposure and force-close avoidance fees for LSPS2 JIT channels - #985

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

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

Conversation

@IgnacioPorte

@IgnacioPorte IgnacioPorte commented Jul 14, 2026 •

Copy link
Copy Markdown

Partially addresses #961 by letting an LSPS2 service configure two settings for newly opened JIT channels:

  • max_dust_htlc_exposure
  • force_close_avoidance_max_fee_satoshis

Unset fields inherit the node-wide channel configuration, and channel_config: None preserves existing behavior. Forwarding fees remain zero. This change does not expose custom CLTV or accept_underpaying_htlcs, and does not update existing channels.

Compatibility: Existing Rust LSPS2ServiceConfig struct literals must add channel_config. The corresponding UniFFI record shape also changes.

Validation: All eight targeted tests passed, covering LSPS2 BOLT11 in both trust models, BOLT12, and six channel lifecycle cases. The UniFFI build and formatting check also passed on 27d8b10.

Developed and reviewed with assistance from Claude Code and OpenAI Codex.

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

@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

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

Excuse the delay here. If we still want to move forward here, this needs a rebase.

Also, claude had a comment:

  1. Medium: a custom cltv_expiry_delta contradicts what the service promises clients. The buy response still always advertises LSPS2_CHANNEL_CLTV_EXPIRY_DELTA (72), at src/liquidity/service/lsps2.rs:31 and :407. The client copies that value into the invoice route hint
    (src/liquidity/client/lsps2.rs:381). With this PR, the JIT channel itself can be opened with a different delta (lsps2.rs:522-524):

    • If the configured delta is above 72: the first intercepted HTLC was routed using a delta of 72. It probably gets rejected when it's forwarded over the new channel because the CLTV is too small. I haven't confirmed this against LDK's intercept-forward path.
    • If it's below 72: the intercepted HTLC still forwards fine, but the advertised 72 no longer matches the channel's actual delta.

    Fix: either pass channel_config.cltv_expiry_delta.unwrap_or(LSPS2_CHANNEL_CLTV_EXPIRY_DELTA) to invoice_parameters_generated, or drop the cltv_expiry_delta field. The test only sets force_close_avoidance_max_fee_satoshis, so this case isn't covered.

Allow LSPS2 services to configure dust HTLC exposure and the maximum
force-close avoidance fee separately from regular channels through an
optional LSPS2ChannelConfig in LSPS2ServiceConfig.

Expose only max_dust_htlc_exposure and
force_close_avoidance_max_fee_satoshis. Unset fields inherit the node-wide
configuration. Forwarding fees remain zero, accept_underpaying_htlcs is
not exposed, and the preexisting CLTV defaults and advertisement are
unchanged.

Extend the LSPS2 integration test to check the configured force-close
avoidance fee and zero base forwarding fee.

This change was developed with the assistance of AI tooling (Claude Code).
This change was developed with assistance from OpenAI Codex.
@IgnacioPorte
IgnacioPorte force-pushed the 2026-07-lsps2-jit-channel-config branch from 21c5981 to 27d8b10 Compare November 27, 2026 16:57
@IgnacioPorte IgnacioPorte changed the title Allow setting a ChannelConfig for LSPS2 JIT channels Configure dust exposure and force-close avoidance fees for LSPS2 JIT channels Nov 27, 2026
@IgnacioPorte

Copy link
Copy Markdown
Author

In response to this review

Thanks for catching the CLTV mismatch. I reproduced it, though the first JIT payment still succeeded in my test. I rebased onto main and removed the custom CLTV option, leaving existing timelock behavior unchanged. All eight targeted tests and the UniFFI build passed.

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.

3 participants