|
8 | 8 | use crate::types::{CustomTlvRecord, DynStore, Sweeper, Wallet}; |
9 | 9 |
|
10 | 10 | 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, |
13 | 13 | }; |
14 | 14 |
|
| 15 | +use crate::config::{may_announce_channel, Config}; |
15 | 16 | use crate::connection::ConnectionManager; |
16 | 17 | use crate::fee_estimator::ConfirmationTarget; |
17 | 18 |
|
@@ -1041,15 +1042,29 @@ where |
1041 | 1042 | funding_satoshis, |
1042 | 1043 | channel_type, |
1043 | 1044 | channel_negotiation_type: _, |
1044 | | - is_announced: _, |
| 1045 | + is_announced, |
1045 | 1046 | params: _, |
1046 | 1047 | } => { |
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 | + ); |
1048 | 1054 |
|
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 | + } |
1052 | 1066 |
|
| 1067 | + let anchor_channel = channel_type.requires_anchors_zero_fee_htlc_tx(); |
1053 | 1068 | if anchor_channel { |
1054 | 1069 | if let Some(anchor_channels_config) = |
1055 | 1070 | self.config.anchor_channels_config.as_ref() |
|
0 commit comments