Conversation
All Node::open_channel variants gain a trailing Option<FeeRate>. When set, the rate is stashed in a pending_funding_fee_rates map keyed by user_channel_id and consumed in the FundingGenerationReady handler, where it overrides the fee estimator's ChannelFunding rate for the funding transaction. When unset, behavior is unchanged. This mirrors the existing fee_rate override on the on-chain send APIs (lightningdevkit#176). For the _with_all variants the override also determines the rate at which the maximum funding amount is computed, so the resulting funding transaction actually fits at the rate it will pay. ChannelClosed clears any still-pending entry, so state stashed for a channel that is rejected or otherwise dies before funding does not leak. This change was developed with the assistance of an AI coding tool (Claude Code).
|
I've assigned @tnull as a reviewer! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Wallet UIs commonly collect a sat/vB fee rate in their channel-open flow, but LDK Node offers no way to apply it: the funding transaction is always built at the internal estimator's
ChannelFundingrate. #176 added exactly this kind of override for the on-chain send APIs; this PR extends the same pattern to channel opens.Surveying ldk-node integrators: Zeus collects an open-channel fee rate in its UI and had to carry this as a downstream fork patch (ZeusLN#6, adapted here to current
main), and Alby Hub and Bitkit currently have no way to offer the option at all through ldk-node's API.Changes
All
Node::open_channelvariants (open_channel,open_announced_channel, the_with_alland_0reservevariants) gain a trailingOption<FeeRate>(FeeRate?in bindings):open_channel_innerstashes the rate in a newpending_funding_fee_rates: Mutex<HashMap<u128, FeeRate>>keyed byuser_channel_idoncecreate_channelsucceedsFundingGenerationReadyhandler removes the entry and passes it toWallet::create_funding_transaction, which now takesOption<FeeRate>and falls back to the estimator whenNone(same shape assend_to_address)FundingAmount::Maxthe override also feedsget_max_funding_amount, so the maximum amount is computed at the rate the funding transaction will actually payChannelClosedclears any still-pending entry, so state stashed for a channel that is rejected or dies before funding does not leakWhen the parameter is unset, behavior is byte-for-byte unchanged.
This is a breaking signature change on the six open methods; a
Feature and API updatesCHANGELOG entry is included, and all internal call sites (tests, doctest) are updated.Testing
cargo check,cargo check --features uniffi, andcargo check --testspasscargo test --lib(196 tests) andcargo test --docpasscargo fmt --all -- --checkcleanAn earlier version of this change (against the 0.7 API) is what Zeus ships; it has unit coverage on the wallet side and device testing pending there.
Disclosure
This change was developed with the assistance of an AI coding tool (Claude Code), per the repository's contribution guidelines.