Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use lightning::ln::msgs::SocketAddress;
use lightning::routing::gossip::NodeAlias;
use lightning::routing::router::RouteParametersConfig;
use lightning::util::config::{
ChannelConfig as LdkChannelConfig, MaxDustHTLCExposure as LdkMaxDustHTLCExposure, UserConfig,
ChannelConfig as LdkChannelConfig, ChannelHandshakeLimits,
MaxDustHTLCExposure as LdkMaxDustHTLCExposure, UserConfig,
};

use crate::logger::LogLevel;
Expand Down Expand Up @@ -125,6 +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` | LDK default |
/// | `anchor_channels_config` | Some(..) |
/// | `route_parameters` | None |
/// | `tor_config` | None |
Expand Down Expand Up @@ -167,6 +169,16 @@ pub struct Config {
/// Channels with available liquidity less than the required amount times this value won't be
/// used to send pre-flight probes.
pub probing_liquidity_limit_multiplier: u64,
/// The minimum funding amount in satoshis that we require from channel counterparties when
/// they open inbound channels to us.
///
/// Channels with funding below this value will be rejected.
///
/// Defaults to the `rust-lightning` value of
/// [`ChannelHandshakeLimits::min_funding_satoshis`].
///
/// [`ChannelHandshakeLimits::min_funding_satoshis`]: lightning::util::config::ChannelHandshakeLimits::min_funding_satoshis
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.
///
Expand Down Expand Up @@ -210,6 +222,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: ChannelHandshakeLimits::default().min_funding_satoshis,
anchor_channels_config: Some(AnchorChannelsConfig::default()),
tor_config: None,
route_parameters: None,
Expand Down Expand Up @@ -339,6 +352,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;
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;
Expand Down Expand Up @@ -637,7 +651,9 @@ pub enum AsyncPaymentsRole {
mod tests {
use std::str::FromStr;

use super::{may_announce_channel, AnnounceError, Config, NodeAlias, SocketAddress};
use super::{
default_user_config, may_announce_channel, AnnounceError, Config, NodeAlias, SocketAddress,
};

#[test]
fn node_announce_channel() {
Expand Down Expand Up @@ -684,4 +700,18 @@ mod tests {
}
assert!(may_announce_channel(&node_config).is_ok());
}

#[test]
fn min_funding_sats_configures_user_config() {
let mut node_config = Config::default();
let user_config = default_user_config(&node_config);
assert_eq!(
user_config.channel_handshake_limits.min_funding_satoshis,
node_config.min_funding_sats
);

node_config.min_funding_sats = 42_000;
let user_config = default_user_config(&node_config);
assert_eq!(user_config.channel_handshake_limits.min_funding_satoshis, 42_000);
}
}
Loading