Skip to content

Commit 6b6a405

Browse files
committed
Drop ChannelHandshakeLimits::max_funding_satoshis
Previously, LDK would by default limit channels pre-Wumbo sizes and leave it to the user to bump `ChannelHandshakeLimits::max_funding_satoshis`. This has mostly historical reasons that aimed to allow limiting risk when Lightning and LDK were not as matured as today. By now, we do however expect ~all users to eventually want to bump this limit, and having them pick an arbitrary value (or pick a default ourselves) is kinda odd. Users that still want to limit risks have ample other means to do so, for example manually rejecting inbound channels via the manual-acceptence flow (via `Event::OpenChannelRequest`) or soon even limiting risk on a per-HTLC basis via general purpose HTLC interception. Furthermore, it turns out that our current implementation is wrong, as we do always announce `Wumbo`/`option_supports_large_channels` support via the `IN` feature in `ChannelManager` defaults, irrespective of what limit is configured. This has us announcing support for Wumbo channels to only then reject inbound requests in case a counterparty dares to actually try to open one. To address this, we here simply propose to drop the `max_funding_satoshis` field and corresponding checks entirely, and do what we've announced to the network for a long time: enable Wumbo by default.
1 parent 5a81e17 commit 6b6a405

File tree

3 files changed

+2
-31
lines changed

3 files changed

+2
-31
lines changed

lightning/src/ln/channel.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,13 +3413,6 @@ where
34133413
return Err(ChannelError::close(format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks. It must be greater than {}", config.channel_handshake_config.our_to_self_delay, BREAKDOWN_TIMEOUT)));
34143414
}
34153415

3416-
// Check sanity of message fields:
3417-
if channel_value_satoshis > config.channel_handshake_limits.max_funding_satoshis {
3418-
return Err(ChannelError::close(format!(
3419-
"Per our config, funding must be at most {}. It was {}. Peer contribution: {}. Our contribution: {}",
3420-
config.channel_handshake_limits.max_funding_satoshis, channel_value_satoshis,
3421-
open_channel_fields.funding_satoshis, our_funding_satoshis)));
3422-
}
34233416
if channel_value_satoshis >= TOTAL_BITCOIN_SUPPLY_SATOSHIS {
34243417
return Err(ChannelError::close(format!("Funding must be smaller than the total bitcoin supply. It was {}", channel_value_satoshis)));
34253418
}
@@ -16068,11 +16061,7 @@ mod tests {
1606816061
use crate::ln::channel::{
1606916062
AwaitingChannelReadyFlags, ChannelState, FundedChannel, HTLCCandidate, HTLCInitiator,
1607016063
HTLCUpdateAwaitingACK, InboundHTLCOutput, InboundHTLCState, InboundV1Channel,
16071-
OutboundHTLCOutput, OutboundHTLCState, OutboundV1Channel,
16072-
};
16073-
use crate::ln::channel::{
16074-
MAX_FUNDING_SATOSHIS_NO_WUMBO, MIN_THEIR_CHAN_RESERVE_SATOSHIS,
16075-
TOTAL_BITCOIN_SUPPLY_SATOSHIS,
16064+
OutboundHTLCOutput, OutboundHTLCState, OutboundV1Channel, MIN_THEIR_CHAN_RESERVE_SATOSHIS,
1607616065
};
1607716066
use crate::ln::channel_keys::{RevocationBasepoint, RevocationKey};
1607816067
use crate::ln::channelmanager::{self, HTLCSource, PaymentId};
@@ -16125,15 +16114,6 @@ mod tests {
1612516114
assert!(ChannelState::ChannelReady(ChannelReadyFlags::new()) < ChannelState::ShutdownComplete);
1612616115
}
1612716116

16128-
#[test]
16129-
fn test_max_funding_satoshis_no_wumbo() {
16130-
assert_eq!(TOTAL_BITCOIN_SUPPLY_SATOSHIS, 21_000_000 * 100_000_000);
16131-
assert!(
16132-
MAX_FUNDING_SATOSHIS_NO_WUMBO <= TOTAL_BITCOIN_SUPPLY_SATOSHIS,
16133-
"MAX_FUNDING_SATOSHIS_NO_WUMBO is greater than all satoshis in existence"
16134-
);
16135-
}
16136-
1613716117
#[cfg(ldk_test_vectors)]
1613816118
struct Keys {
1613916119
signer: crate::sign::InMemorySigner,

lightning/src/ln/channel_open_tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,7 @@ fn test_channel_resumption_fail_post_funding() {
499499
pub fn test_insane_channel_opens() {
500500
// Stand up a network of 2 nodes
501501
use crate::ln::channel::TOTAL_BITCOIN_SUPPLY_SATOSHIS;
502-
let mut cfg = UserConfig::default();
503-
cfg.channel_handshake_limits.max_funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1;
502+
let cfg = UserConfig::default();
504503
let chanmon_cfgs = create_chanmon_cfgs(2);
505504
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
506505
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(cfg.clone())]);

lightning/src/util/config.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//! Various user-configurable channel limits and settings which ChannelManager
1111
//! applies for you.
1212
13-
use crate::ln::channel::MAX_FUNDING_SATOSHIS_NO_WUMBO;
1413
use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT};
1514

1615
#[cfg(fuzzing)]
@@ -302,11 +301,6 @@ pub struct ChannelHandshakeLimits {
302301
/// Default value: `1000`
303302
/// (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`])
304303
pub min_funding_satoshis: u64,
305-
/// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
306-
/// only applies to inbound channels.
307-
///
308-
/// Default value: `2^24 - 1`
309-
pub max_funding_satoshis: u64,
310304
/// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
311305
/// you to limit the maximum minimum-size they can require.
312306
///
@@ -376,7 +370,6 @@ impl Default for ChannelHandshakeLimits {
376370
fn default() -> Self {
377371
ChannelHandshakeLimits {
378372
min_funding_satoshis: 1000,
379-
max_funding_satoshis: MAX_FUNDING_SATOSHIS_NO_WUMBO,
380373
max_htlc_minimum_msat: u64::MAX,
381374
min_max_htlc_value_in_flight_msat: 0,
382375
max_channel_reserve_satoshis: u64::MAX,
@@ -397,7 +390,6 @@ impl Readable for ChannelHandshakeLimits {
397390
fn read<R: crate::io::Read>(reader: &mut R) -> Result<Self, crate::ln::msgs::DecodeError> {
398391
Ok(Self {
399392
min_funding_satoshis: Readable::read(reader)?,
400-
max_funding_satoshis: Readable::read(reader)?,
401393
max_htlc_minimum_msat: Readable::read(reader)?,
402394
min_max_htlc_value_in_flight_msat: Readable::read(reader)?,
403395
max_channel_reserve_satoshis: Readable::read(reader)?,

0 commit comments

Comments
 (0)