Skip to content

Commit 3af4165

Browse files
fixup! off by one
1 parent a2aceb1 commit 3af4165

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning/src/ln/channel.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,8 @@ pub const ANCHOR_OUTPUT_VALUE_SATOSHI: u64 = 330;
736736

737737
/// Maximum `funding_satoshis` value according to the BOLT #2 specification, if
738738
/// `option_support_large_channel` (aka wumbo channels) is not supported.
739-
/// It's 2^24.
740-
pub const MAX_FUNDING_SATOSHIS_NO_WUMBO: u64 = 1 << 24;
739+
/// It's 2^24 - 1.
740+
pub const MAX_FUNDING_SATOSHIS_NO_WUMBO: u64 = (1 << 24) - 1;
741741

742742
/// Total bitcoin supply in satoshis.
743743
pub const TOTAL_BITCOIN_SUPPLY_SATOSHIS: u64 = 21_000_000 * 1_0000_0000;
@@ -854,7 +854,7 @@ impl<Signer: Sign> Channel<Signer> {
854854
let holder_signer = keys_provider.get_channel_signer(false, channel_value_satoshis);
855855
let pubkeys = holder_signer.pubkeys().clone();
856856

857-
if !their_features.supports_wumbo() && channel_value_satoshis >= MAX_FUNDING_SATOSHIS_NO_WUMBO {
857+
if !their_features.supports_wumbo() && channel_value_satoshis > MAX_FUNDING_SATOSHIS_NO_WUMBO {
858858
return Err(APIError::APIMisuseError{err: format!("funding_value must not exceed {}, it was {}", MAX_FUNDING_SATOSHIS_NO_WUMBO, channel_value_satoshis)});
859859
}
860860
if channel_value_satoshis >= TOTAL_BITCOIN_SUPPLY_SATOSHIS {
@@ -1083,7 +1083,7 @@ impl<Signer: Sign> Channel<Signer> {
10831083
}
10841084

10851085
// Check sanity of message fields:
1086-
if msg.funding_satoshis >= config.peer_channel_config_limits.max_funding_satoshis {
1086+
if msg.funding_satoshis > config.peer_channel_config_limits.max_funding_satoshis {
10871087
return Err(ChannelError::Close(format!("Per our config, funding must be at most {}. It was {}", config.peer_channel_config_limits.max_funding_satoshis, msg.funding_satoshis)));
10881088
}
10891089
if msg.funding_satoshis >= TOTAL_BITCOIN_SUPPLY_SATOSHIS {

0 commit comments

Comments
 (0)