Skip to content

Commit b6bd386

Browse files
committed
Fix off-by-one for unfunded channel peers
When accepting channels manually, it would fail if the # of peers without funded channels was == `MAX_UNFUNDED_CHANNEL_PEERS`, however, it should fail if the # of peers > `MAX_UNFUNDED_CHANNEL_PEERS`.
1 parent f43803d commit b6bd386

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lightning/src/ln/channel_open_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn test_0conf_limiting() {
110110
};
111111

112112
// First, get us up to MAX_UNFUNDED_CHANNEL_PEERS so we can test at the edge
113-
for _ in 0..MAX_UNFUNDED_CHANNEL_PEERS - 1 {
113+
for _ in 0..MAX_UNFUNDED_CHANNEL_PEERS {
114114
let random_pk = PublicKey::from_secret_key(
115115
&nodes[0].node.secp_ctx,
116116
&SecretKey::from_slice(&nodes[1].keys_manager.get_secure_random_bytes()).unwrap(),

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10569,7 +10569,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1056910569
// If this peer already has some channels, a new channel won't increase our number of peers
1057010570
// with unfunded channels, so as long as we aren't over the maximum number of unfunded
1057110571
// channels per-peer we can accept channels from a peer with existing ones.
10572-
if is_only_peer_channel && peers_without_funded_channels >= MAX_UNFUNDED_CHANNEL_PEERS {
10572+
if is_only_peer_channel && peers_without_funded_channels > MAX_UNFUNDED_CHANNEL_PEERS {
1057310573
let send_msg_err_event = MessageSendEvent::HandleError {
1057410574
node_id: channel.context().get_counterparty_node_id(),
1057510575
action: msgs::ErrorAction::SendErrorMessage {

0 commit comments

Comments
 (0)