Repository navigation
Configure dust exposure and force-close avoidance fees for LSPS2 JIT channels - #985
IgnacioPorte wants to merge 1 commit into
Conversation
|
👋 Thanks for assigning @tnull as a reviewer! |
tnull
left a comment
There was a problem hiding this comment.
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.
| /// 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 |
There was a problem hiding this comment.
It's odd to reuse the object, but then honor only a few fields of it.
There was a problem hiding this comment.
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.
b94b182 to
21c5981
Compare
tnull
left a comment
There was a problem hiding this comment.
Excuse the delay here. If we still want to move forward here, this needs a rebase.
Also, claude had a comment:
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.
21c5981 to
27d8b10
Compare
|
Thanks for catching the CLTV mismatch. I reproduced it, though the first JIT payment still succeeded in my test. I rebased onto |
Partially addresses #961 by letting an LSPS2 service configure two settings for newly opened JIT channels:
max_dust_htlc_exposureforce_close_avoidance_max_fee_satoshisUnset fields inherit the node-wide channel configuration, and
channel_config: Nonepreserves existing behavior. Forwarding fees remain zero. This change does not expose custom CLTV oraccept_underpaying_htlcs, and does not update existing channels.Compatibility: Existing Rust
LSPS2ServiceConfigstruct literals must addchannel_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.