@@ -48,7 +48,9 @@ use crate::events::{self, Event, EventHandler, EventsProvider, InboundChannelFun
4848use crate::ln::inbound_payment;
4949use crate::ln::types::ChannelId;
5050use crate::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
51- use crate::ln::channel::{self, Channel, ChannelPhase, ChannelError, ChannelUpdateStatus, ShutdownResult, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel, WithChannelContext, InboundV2Channel, InteractivelyFunded as _};
51+ use crate::ln::channel::{self, Channel, ChannelPhase, ChannelError, ChannelUpdateStatus, ShutdownResult, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel, WithChannelContext, InteractivelyFunded as _};
52+ #[cfg(any(dual_funding, splicing))]
53+ use crate::ln::channel::InboundV2Channel;
5254use crate::ln::channel_state::ChannelDetails;
5355use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
5456#[cfg(any(feature = "_test_utils", test))]
@@ -1391,11 +1393,13 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
13911393#[derive(Clone)]
13921394pub(super) enum OpenChannelMessage {
13931395 V1(msgs::OpenChannel),
1396+ #[cfg(dual_funding)]
13941397 V2(msgs::OpenChannelV2),
13951398}
13961399
13971400pub(super) enum OpenChannelMessageRef<'a> {
13981401 V1(&'a msgs::OpenChannel),
1402+ #[cfg(dual_funding)]
13991403 V2(&'a msgs::OpenChannelV2),
14001404}
14011405
@@ -7651,8 +7655,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
76517655
76527656 fn do_accept_inbound_channel(
76537657 &self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, accept_0conf: bool,
7654- user_channel_id: u128, funding_inputs : Vec<(TxIn, TransactionU16LenLimited)>,
7655- total_witness_weight : Weight,
7658+ user_channel_id: u128, _funding_inputs : Vec<(TxIn, TransactionU16LenLimited)>,
7659+ _total_witness_weight : Weight,
76567660 ) -> Result<(), APIError> {
76577661 let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id), None);
76587662 let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
@@ -7696,10 +7700,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
76967700 (*temporary_channel_id, ChannelPhase::UnfundedInboundV1(channel), message_send_event)
76977701 })
76987702 },
7703+ #[cfg(dual_funding)]
76997704 OpenChannelMessage::V2(open_channel_msg) => {
77007705 InboundV2Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
77017706 self.get_our_node_id(), *counterparty_node_id, &self.channel_type_features(), &peer_state.latest_features,
7702- &open_channel_msg, funding_inputs, total_witness_weight , user_channel_id,
7707+ &open_channel_msg, _funding_inputs, _total_witness_weight , user_channel_id,
77037708 &self.default_configuration, best_block_height, &self.logger
77047709 ).map_err(|_| MsgHandleErrInternal::from_chan_no_close(
77057710 ChannelError::Close(
@@ -7852,6 +7857,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
78527857 fn internal_open_channel(&self, counterparty_node_id: &PublicKey, msg: OpenChannelMessageRef<'_>) -> Result<(), MsgHandleErrInternal> {
78537858 let common_fields = match msg {
78547859 OpenChannelMessageRef::V1(msg) => &msg.common_fields,
7860+ #[cfg(dual_funding)]
78557861 OpenChannelMessageRef::V2(msg) => &msg.common_fields,
78567862 };
78577863
@@ -7929,6 +7935,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
79297935 funding_satoshis: common_fields.funding_satoshis,
79307936 channel_negotiation_type: match msg {
79317937 OpenChannelMessageRef::V1(msg) => InboundChannelFunds::PushMsat(msg.push_msat),
7938+ #[cfg(dual_funding)]
79327939 OpenChannelMessageRef::V2(_) => InboundChannelFunds::DualFunded,
79337940 },
79347941 channel_type,
@@ -7938,6 +7945,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
79387945 peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {
79397946 open_channel_msg: match msg {
79407947 OpenChannelMessageRef::V1(msg) => OpenChannelMessage::V1(msg.clone()),
7948+ #[cfg(dual_funding)]
79417949 OpenChannelMessageRef::V2(msg) => OpenChannelMessage::V2(msg.clone()),
79427950 },
79437951 ticks_remaining: UNACCEPTED_INBOUND_CHANNEL_AGE_LIMIT_TICKS,
@@ -7973,6 +7981,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
79737981 });
79747982 (ChannelPhase::UnfundedInboundV1(channel), message_send_event)
79757983 },
7984+ #[cfg(dual_funding)]
79767985 OpenChannelMessageRef::V2(msg) => {
79777986 let channel = InboundV2Channel::new(&self.fee_estimator, &self.entropy_source,
79787987 &self.signer_provider, self.get_our_node_id(), *counterparty_node_id,
@@ -11271,6 +11280,7 @@ where
1127111280 // Note that we never need to persist the updated ChannelManager for an inbound
1127211281 // open_channel message - pre-funded channels are never written so there should be no
1127311282 // change to the contents.
11283+ #[cfg(dual_funding)]
1127411284 let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
1127511285 let res = self.internal_open_channel(&counterparty_node_id, OpenChannelMessageRef::V2(msg));
1127611286 let persist = match &res {
@@ -11283,6 +11293,10 @@ where
1128311293 let _ = handle_error!(self, res, counterparty_node_id);
1128411294 persist
1128511295 });
11296+ #[cfg(not(dual_funding))]
11297+ let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
11298+ "Dual-funded channels not supported".to_owned(),
11299+ msg.common_fields.temporary_channel_id.clone())), counterparty_node_id);
1128611300 }
1128711301
1128811302 fn handle_accept_channel(&self, counterparty_node_id: PublicKey, msg: &msgs::AcceptChannel) {
@@ -12334,6 +12348,7 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
1233412348 if config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx {
1233512349 features.set_anchors_zero_fee_htlc_tx_optional();
1233612350 }
12351+ #[cfg(dual_funding)]
1233712352 features.set_dual_fund_optional();
1233812353 features
1233912354}
0 commit comments