Skip to content

Commit

Permalink
Merge pull request #467 from tnull/2025-02-reject-inbound-channels-if…
Browse files Browse the repository at this point in the history
…-not-forwarding

Reject inbound announced channels if not all requirements are met
  • Loading branch information
tnull authored Feb 12, 2025
2 parents 7e6f9c1 + 38a24c9 commit 9607af3
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
use crate::types::{CustomTlvRecord, DynStore, Sweeper, Wallet};

use crate::{
hex_utils, BumpTransactionEventHandler, ChannelManager, Config, Error, Graph, PeerInfo,
PeerStore, UserChannelId,
hex_utils, BumpTransactionEventHandler, ChannelManager, Error, Graph, PeerInfo, PeerStore,
UserChannelId,
};

use crate::config::{may_announce_channel, Config};
use crate::connection::ConnectionManager;
use crate::fee_estimator::ConfirmationTarget;

Expand Down Expand Up @@ -1041,15 +1042,29 @@ where
funding_satoshis,
channel_type,
channel_negotiation_type: _,
is_announced: _,
is_announced,
params: _,
} => {
let anchor_channel = channel_type.requires_anchors_zero_fee_htlc_tx();
if is_announced && !may_announce_channel(&*self.config) {
log_error!(
self.logger,
"Rejecting inbound announced channel from peer {} as not all required details are set. Please ensure node alias and listening addresses have been configured.",
counterparty_node_id,
);

// TODO: We should use `is_announced` flag above and reject announced channels if
// we're not a forwading node, once we add a 'forwarding mode' based on listening
// address / node alias being set.
self.channel_manager
.force_close_without_broadcasting_txn(
&temporary_channel_id,
&counterparty_node_id,
"Channel request rejected".to_string(),
)
.unwrap_or_else(|e| {
log_error!(self.logger, "Failed to reject channel: {:?}", e)
});
return Ok(());
}

let anchor_channel = channel_type.requires_anchors_zero_fee_htlc_tx();
if anchor_channel {
if let Some(anchor_channels_config) =
self.config.anchor_channels_config.as_ref()
Expand Down

0 comments on commit 9607af3

Please sign in to comment.