Skip to content
Open
Show file tree
Hide file tree
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
22 changes: 1 addition & 21 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3413,13 +3413,6 @@ where
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)));
}

// Check sanity of message fields:
if channel_value_satoshis > config.channel_handshake_limits.max_funding_satoshis {
return Err(ChannelError::close(format!(
"Per our config, funding must be at most {}. It was {}. Peer contribution: {}. Our contribution: {}",
config.channel_handshake_limits.max_funding_satoshis, channel_value_satoshis,
open_channel_fields.funding_satoshis, our_funding_satoshis)));
}
if channel_value_satoshis >= TOTAL_BITCOIN_SUPPLY_SATOSHIS {
return Err(ChannelError::close(format!("Funding must be smaller than the total bitcoin supply. It was {}", channel_value_satoshis)));
}
Expand Down Expand Up @@ -16068,11 +16061,7 @@ mod tests {
use crate::ln::channel::{
AwaitingChannelReadyFlags, ChannelState, FundedChannel, HTLCCandidate, HTLCInitiator,
HTLCUpdateAwaitingACK, InboundHTLCOutput, InboundHTLCState, InboundV1Channel,
OutboundHTLCOutput, OutboundHTLCState, OutboundV1Channel,
};
use crate::ln::channel::{
MAX_FUNDING_SATOSHIS_NO_WUMBO, MIN_THEIR_CHAN_RESERVE_SATOSHIS,
TOTAL_BITCOIN_SUPPLY_SATOSHIS,
OutboundHTLCOutput, OutboundHTLCState, OutboundV1Channel, MIN_THEIR_CHAN_RESERVE_SATOSHIS,
};
use crate::ln::channel_keys::{RevocationBasepoint, RevocationKey};
use crate::ln::channelmanager::{self, HTLCSource, PaymentId};
Expand Down Expand Up @@ -16125,15 +16114,6 @@ mod tests {
assert!(ChannelState::ChannelReady(ChannelReadyFlags::new()) < ChannelState::ShutdownComplete);
}

#[test]
fn test_max_funding_satoshis_no_wumbo() {
assert_eq!(TOTAL_BITCOIN_SUPPLY_SATOSHIS, 21_000_000 * 100_000_000);
assert!(
MAX_FUNDING_SATOSHIS_NO_WUMBO <= TOTAL_BITCOIN_SUPPLY_SATOSHIS,
"MAX_FUNDING_SATOSHIS_NO_WUMBO is greater than all satoshis in existence"
);
}

#[cfg(ldk_test_vectors)]
struct Keys {
signer: crate::sign::InMemorySigner,
Expand Down
16 changes: 1 addition & 15 deletions lightning/src/ln/channel_open_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,7 @@ fn test_channel_resumption_fail_post_funding() {
pub fn test_insane_channel_opens() {
// Stand up a network of 2 nodes
use crate::ln::channel::TOTAL_BITCOIN_SUPPLY_SATOSHIS;
let mut cfg = UserConfig::default();
cfg.channel_handshake_limits.max_funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1;
let cfg = UserConfig::default();
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(cfg.clone())]);
Expand Down Expand Up @@ -550,19 +549,6 @@ pub fn test_insane_channel_opens() {

use crate::ln::channelmanager::MAX_LOCAL_BREAKDOWN_TIMEOUT;

// Test all mutations that would make the channel open message insane
insane_open_helper(
format!(
"Per our config, funding must be at most {}. It was {}",
TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1,
TOTAL_BITCOIN_SUPPLY_SATOSHIS + 2
)
.as_str(),
|mut msg| {
msg.common_fields.funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 2;
msg
},
);
insane_open_helper(
format!(
"Funding must be smaller than the total bitcoin supply. It was {}",
Expand Down
8 changes: 0 additions & 8 deletions lightning/src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//! Various user-configurable channel limits and settings which ChannelManager
//! applies for you.

use crate::ln::channel::MAX_FUNDING_SATOSHIS_NO_WUMBO;
use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT};

#[cfg(fuzzing)]
Expand Down Expand Up @@ -302,11 +301,6 @@ pub struct ChannelHandshakeLimits {
/// Default value: `1000`
/// (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`])
pub min_funding_satoshis: u64,
/// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
/// only applies to inbound channels.
///
/// Default value: `2^24 - 1`
pub max_funding_satoshis: u64,
/// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
/// you to limit the maximum minimum-size they can require.
///
Expand Down Expand Up @@ -376,7 +370,6 @@ impl Default for ChannelHandshakeLimits {
fn default() -> Self {
ChannelHandshakeLimits {
min_funding_satoshis: 1000,
max_funding_satoshis: MAX_FUNDING_SATOSHIS_NO_WUMBO,
max_htlc_minimum_msat: u64::MAX,
min_max_htlc_value_in_flight_msat: 0,
max_channel_reserve_satoshis: u64::MAX,
Expand All @@ -397,7 +390,6 @@ impl Readable for ChannelHandshakeLimits {
fn read<R: crate::io::Read>(reader: &mut R) -> Result<Self, crate::ln::msgs::DecodeError> {
Ok(Self {
min_funding_satoshis: Readable::read(reader)?,
max_funding_satoshis: Readable::read(reader)?,
max_htlc_minimum_msat: Readable::read(reader)?,
min_max_htlc_value_in_flight_msat: Readable::read(reader)?,
max_channel_reserve_satoshis: Readable::read(reader)?,
Expand Down
Loading