Skip to content

Commit 55e5f6f

Browse files
committed
Add enable_dual_funded_channels to UserConfig
1 parent ac3b317 commit 55e5f6f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lightning/src/ln/channelmanager.rs

+6
Original file line numberDiff line numberDiff line change
@@ -11982,6 +11982,12 @@ where
1198211982
}
1198311983

1198411984
fn handle_open_channel_v2(&self, counterparty_node_id: PublicKey, msg: &msgs::OpenChannelV2) {
11985+
if !self.default_configuration.enable_dual_funded_channels {
11986+
let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
11987+
"Dual-funded channels not supported".to_owned(),
11988+
msg.common_fields.temporary_channel_id.clone())), counterparty_node_id);
11989+
return;
11990+
}
1198511991
// Note that we never need to persist the updated ChannelManager for an inbound
1198611992
// open_channel message - pre-funded channels are never written so there should be no
1198711993
// change to the contents.

lightning/src/ln/dual_funding_tests.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ struct V2ChannelEstablishmentTestSession {
3939
fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession) {
4040
let chanmon_cfgs = create_chanmon_cfgs(2);
4141
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
42-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
42+
let mut node_1_user_config = test_default_channel_config();
43+
node_1_user_config.enable_dual_funded_channels = true;
44+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(node_1_user_config)]);
4345
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
4446
let logger_a = test_utils::TestLogger::with_id("node a".to_owned());
4547

lightning/src/util/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@ pub struct UserConfig {
878878
/// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice
879879
/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
880880
pub manually_handle_bolt12_invoices: bool,
881+
/// If this is set to `true`, dual-funded channels will be enabled.
882+
///
883+
/// Default value: `false`
884+
pub enable_dual_funded_channels: bool,
881885
}
882886

883887
impl Default for UserConfig {
@@ -891,6 +895,7 @@ impl Default for UserConfig {
891895
manually_accept_inbound_channels: false,
892896
accept_intercept_htlcs: false,
893897
manually_handle_bolt12_invoices: false,
898+
enable_dual_funded_channels: false,
894899
}
895900
}
896901
}
@@ -910,6 +915,7 @@ impl Readable for UserConfig {
910915
manually_accept_inbound_channels: Readable::read(reader)?,
911916
accept_intercept_htlcs: Readable::read(reader)?,
912917
manually_handle_bolt12_invoices: Readable::read(reader)?,
918+
enable_dual_funded_channels: Readable::read(reader)?,
913919
})
914920
}
915921
}

0 commit comments

Comments
 (0)