Add 'accept_inbound_channels' config option.
authorElias Rohrer <elias.rohrer@tu-berlin.de>
Wed, 17 Nov 2021 17:54:47 +0000 (18:54 +0100)
committerElias Rohrer <elias.rohrer@tu-berlin.de>
Wed, 17 Nov 2021 17:54:47 +0000 (18:54 +0100)
lightning/src/ln/channelmanager.rs
lightning/src/util/config.rs

index 9e0fc3ebb5e599ef4bde11671f2befcd13e26e86..1e60dcdccd401538cf4b2210b030024818e2ef17 100644 (file)
@@ -3646,6 +3646,10 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                        return Err(MsgHandleErrInternal::send_err_msg_no_close("Unknown genesis block hash".to_owned(), msg.temporary_channel_id.clone()));
                }
 
+               if !self.default_configuration.accept_inbound_channels {
+                       return Err(MsgHandleErrInternal::send_err_msg_no_close("No inbound channels accepted".to_owned(), msg.temporary_channel_id.clone()));
+               }
+
                let channel = Channel::new_from_req(&self.fee_estimator, &self.keys_manager, counterparty_node_id.clone(),
                                &their_features, msg, 0, &self.default_configuration, self.best_block.read().unwrap().height())
                        .map_err(|e| MsgHandleErrInternal::from_chan_no_close(e, msg.temporary_channel_id))?;
index fb4f6fce737fb1eb47c8cb95abcc8ae69d5ef3b4..c591cacb3463fd6e216a24da8390bdce6ddde1f9 100644 (file)
@@ -302,6 +302,9 @@ pub struct UserConfig {
        ///
        /// Default value: false.
        pub accept_forwards_to_priv_channels: bool,
+       /// If this is set to false, we do not accept inbound requests to open a new channel.
+       /// Default value: true.
+       pub accept_inbound_channels: bool,
 }
 
 impl Default for UserConfig {
@@ -311,6 +314,7 @@ impl Default for UserConfig {
                        peer_channel_config_limits: ChannelHandshakeLimits::default(),
                        channel_options: ChannelConfig::default(),
                        accept_forwards_to_priv_channels: false,
+                       accept_inbound_channels: true,
                }
        }
 }