Skip to content

Commit 38a24c9

Browse files
committed
Reject inbound announced channels if not all requirements are met
In particular, reject inbound announced channels if node alias and listening addresses are not set. We previously enforced this for outbound channels, here we start enforcing this check for inbound channels, too.
1 parent 7e6f9c1 commit 38a24c9

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/event.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
use crate::types::{CustomTlvRecord, DynStore, Sweeper, Wallet};
99

1010
use crate::{
11-
hex_utils, BumpTransactionEventHandler, ChannelManager, Config, Error, Graph, PeerInfo,
12-
PeerStore, UserChannelId,
11+
hex_utils, BumpTransactionEventHandler, ChannelManager, Error, Graph, PeerInfo, PeerStore,
12+
UserChannelId,
1313
};
1414

15+
use crate::config::{may_announce_channel, Config};
1516
use crate::connection::ConnectionManager;
1617
use crate::fee_estimator::ConfirmationTarget;
1718

@@ -1041,15 +1042,29 @@ where
10411042
funding_satoshis,
10421043
channel_type,
10431044
channel_negotiation_type: _,
1044-
is_announced: _,
1045+
is_announced,
10451046
params: _,
10461047
} => {
1047-
let anchor_channel = channel_type.requires_anchors_zero_fee_htlc_tx();
1048+
if is_announced && !may_announce_channel(&*self.config) {
1049+
log_error!(
1050+
self.logger,
1051+
"Rejecting inbound announced channel from peer {} as not all required details are set. Please ensure node alias and listening addresses have been configured.",
1052+
counterparty_node_id,
1053+
);
10481054

1049-
// TODO: We should use `is_announced` flag above and reject announced channels if
1050-
// we're not a forwading node, once we add a 'forwarding mode' based on listening
1051-
// address / node alias being set.
1055+
self.channel_manager
1056+
.force_close_without_broadcasting_txn(
1057+
&temporary_channel_id,
1058+
&counterparty_node_id,
1059+
"Channel request rejected".to_string(),
1060+
)
1061+
.unwrap_or_else(|e| {
1062+
log_error!(self.logger, "Failed to reject channel: {:?}", e)
1063+
});
1064+
return Ok(());
1065+
}
10521066

1067+
let anchor_channel = channel_type.requires_anchors_zero_fee_htlc_tx();
10531068
if anchor_channel {
10541069
if let Some(anchor_channels_config) =
10551070
self.config.anchor_channels_config.as_ref()

0 commit comments

Comments
 (0)