Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject inbound announced channels if not all requirements are met #467

Merged
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
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
Loading