Skip to content

Expose min_funding_satoshis via Config#844

Draft
vincenzopalazzo wants to merge 2 commits intolightningdevkit:mainfrom
vincenzopalazzo:claude/goofy-jemison
Draft

Expose min_funding_satoshis via Config#844
vincenzopalazzo wants to merge 2 commits intolightningdevkit:mainfrom
vincenzopalazzo:claude/goofy-jemison

Conversation

@vincenzopalazzo
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo commented Mar 25, 2026

Summary

  • Add min_funding_sats field to Config that maps to LDK's ChannelHandshakeLimits::min_funding_satoshis
  • Server operators can now enforce a higher minimum channel funding amount for inbound channels (default remains 1000 sats)
  • Updated UniFFI bindings

Fixes #842

Test plan

  • cargo check passes
  • cargo test --lib config passes
  • CI passes

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
AI-assisted-by: OpenAI Codex

cc @tankyleo

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 25, 2026

👋 Hi! This PR is now in draft status.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@ldk-reviews-bot ldk-reviews-bot requested a review from tnull March 25, 2026 11:15
@vincenzopalazzo vincenzopalazzo force-pushed the claude/goofy-jemison branch 2 times, most recently from 44bc110 to 2f8c8ab Compare March 25, 2026 11:53
@tankyleo tankyleo self-requested a review March 25, 2026 16:40
Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

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

I would have cleaned it up like this; I don't think it's worth adding the Option there, the config setting logically is just a single number.

diff --git a/src/config.rs b/src/config.rs
index ffd9d134..d6402257 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -28,6 +28,7 @@ const DEFAULT_LDK_WALLET_SYNC_INTERVAL_SECS: u64 = 30;
 const DEFAULT_FEE_RATE_CACHE_UPDATE_INTERVAL_SECS: u64 = 60 * 10;
 const DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER: u64 = 3;
 const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS: u64 = 25_000;
+const DEFAULT_MIN_FUNDING_SATS: u64 = 1000;

 // The default timeout after which we abort a wallet syncing operation.
 const DEFAULT_BDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 60;
@@ -125,7 +126,7 @@ pub(crate) const LNURL_AUTH_TIMEOUT_SECS: u64 = 15;
 /// | `node_alias`                           | None               |
 /// | `trusted_peers_0conf`                  | []                 |
 /// | `probing_liquidity_limit_multiplier`   | 3                  |
-/// | `min_funding_sats`                     | None               |
+/// | `min_funding_sats`                     | 1000               |
 /// | `anchor_channels_config`               | Some(..)           |
 /// | `route_parameters`                     | None               |
 /// | `tor_config`                           | None               |
@@ -172,13 +173,7 @@ pub struct Config {
        /// they open inbound channels to us.
        ///
        /// Channels with funding below this value will be rejected.
-       ///
-       /// If unset, the `rust-lightning` default of `1000` sats will be used.
-       ///
-       /// Please refer to [`ChannelHandshakeLimits::min_funding_satoshis`] for further details.
-       ///
-       /// [`ChannelHandshakeLimits::min_funding_satoshis`]: lightning::util::config::ChannelHandshakeLimits::min_funding_satoshis
-       pub min_funding_sats: Option<u64>,
+       pub min_funding_sats: u64,
        /// Configuration options pertaining to Anchor channels, i.e., channels for which the
        /// `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
        ///
@@ -222,7 +217,7 @@ impl Default for Config {
                        announcement_addresses: None,
                        trusted_peers_0conf: Vec::new(),
                        probing_liquidity_limit_multiplier: DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER,
-                       min_funding_sats: None,
+                       min_funding_sats: DEFAULT_MIN_FUNDING_SATS,
                        anchor_channels_config: Some(AnchorChannelsConfig::default()),
                        tor_config: None,
                        route_parameters: None,
@@ -352,9 +347,7 @@ pub(crate) fn default_user_config(config: &Config) -> UserConfig {
        // will mostly be relevant for inbound channels.
        let mut user_config = UserConfig::default();
        user_config.channel_handshake_limits.force_announced_channel_preference = false;
-       if let Some(min_funding_sats) = config.min_funding_sats {
-               user_config.channel_handshake_limits.min_funding_satoshis = min_funding_sats;
-       }
+       user_config.channel_handshake_limits.min_funding_satoshis = config.min_funding_sats;
        user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx =
                config.anchor_channels_config.is_some();
        user_config.reject_inbound_splices = false;

@vincenzopalazzo
Copy link
Contributor Author

@tankyleo Fixed in e2113b3. Switched Config::min_funding_sats to a plain u64 with an explicit 1000-sat default, removed the conditional assignment into the LDK user config, and added a unit test covering both the default and override path.

Add `min_funding_sats` to `Config` and map it to LDK's
`ChannelHandshakeLimits::min_funding_satoshis`. Use a plain `u64` with
an explicit default and cover both the default and override behavior with
a unit test so operators can enforce a higher minimum inbound channel
funding amount.

Fixes lightningdevkit#842

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
AI-assisted-by: Codex
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Thanks, but see #842 (comment)

For all values we'd also still want to fill them from LDK's defaults, not define our own default values in LDK Node as far as possible, as that would risk them getting out-of-sync at some point.

…nstant

Derive min_funding_sats default from ChannelHandshakeLimits::default()
to avoid the values getting out-of-sync between LDK and LDK Node.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vincenzopalazzo vincenzopalazzo marked this pull request as draft March 27, 2026 08:57
@vincenzopalazzo
Copy link
Contributor Author

vincenzopalazzo commented Mar 27, 2026

Moving the discussion on the issue #842 (comment) and moving the PR as a draft while we have the discussion going

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.

Expose UserConfig::channel_handshake_limits::min_funding_satoshis

4 participants