@@ -48,7 +48,9 @@ use crate::events::{self, Event, EventHandler, EventsProvider, InboundChannelFun
48
48
use crate::ln::inbound_payment;
49
49
use crate::ln::types::ChannelId;
50
50
use 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(dual_funding)]
53
+ use crate::ln::channel::InboundV2Channel;
52
54
use crate::ln::channel_state::ChannelDetails;
53
55
use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
54
56
#[cfg(any(feature = "_test_utils", test))]
@@ -1376,11 +1378,13 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
1376
1378
#[derive(Clone)]
1377
1379
pub(super) enum OpenChannelMessage {
1378
1380
V1(msgs::OpenChannel),
1381
+ #[cfg(dual_funding)]
1379
1382
V2(msgs::OpenChannelV2),
1380
1383
}
1381
1384
1382
1385
pub(super) enum OpenChannelMessageRef<'a> {
1383
1386
V1(&'a msgs::OpenChannel),
1387
+ #[cfg(dual_funding)]
1384
1388
V2(&'a msgs::OpenChannelV2),
1385
1389
}
1386
1390
@@ -7686,8 +7690,8 @@ where
7686
7690
7687
7691
fn do_accept_inbound_channel(
7688
7692
&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, accept_0conf: bool,
7689
- user_channel_id: u128, funding_inputs : Vec<(TxIn, TransactionU16LenLimited)>,
7690
- total_witness_weight : Weight,
7693
+ user_channel_id: u128, _funding_inputs : Vec<(TxIn, TransactionU16LenLimited)>,
7694
+ _total_witness_weight : Weight,
7691
7695
) -> Result<(), APIError> {
7692
7696
let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id), None);
7693
7697
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
@@ -7728,10 +7732,11 @@ where
7728
7732
(*temporary_channel_id, ChannelPhase::UnfundedInboundV1(channel), message_send_event)
7729
7733
})
7730
7734
},
7735
+ #[cfg(dual_funding)]
7731
7736
OpenChannelMessage::V2(open_channel_msg) => {
7732
7737
InboundV2Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
7733
7738
self.get_our_node_id(), *counterparty_node_id, &self.channel_type_features(), &peer_state.latest_features,
7734
- &open_channel_msg, funding_inputs, total_witness_weight , user_channel_id,
7739
+ &open_channel_msg, _funding_inputs, _total_witness_weight , user_channel_id,
7735
7740
&self.default_configuration, best_block_height, &self.logger
7736
7741
).map_err(|_| MsgHandleErrInternal::from_chan_no_close(
7737
7742
ChannelError::Close(
@@ -7882,6 +7887,7 @@ where
7882
7887
fn internal_open_channel(&self, counterparty_node_id: &PublicKey, msg: OpenChannelMessageRef<'_>) -> Result<(), MsgHandleErrInternal> {
7883
7888
let common_fields = match msg {
7884
7889
OpenChannelMessageRef::V1(msg) => &msg.common_fields,
7890
+ #[cfg(dual_funding)]
7885
7891
OpenChannelMessageRef::V2(msg) => &msg.common_fields,
7886
7892
};
7887
7893
@@ -7959,6 +7965,7 @@ where
7959
7965
funding_satoshis: common_fields.funding_satoshis,
7960
7966
channel_negotiation_type: match msg {
7961
7967
OpenChannelMessageRef::V1(msg) => InboundChannelFunds::PushMsat(msg.push_msat),
7968
+ #[cfg(dual_funding)]
7962
7969
OpenChannelMessageRef::V2(_) => InboundChannelFunds::DualFunded,
7963
7970
},
7964
7971
channel_type,
@@ -7968,6 +7975,7 @@ where
7968
7975
peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {
7969
7976
open_channel_msg: match msg {
7970
7977
OpenChannelMessageRef::V1(msg) => OpenChannelMessage::V1(msg.clone()),
7978
+ #[cfg(dual_funding)]
7971
7979
OpenChannelMessageRef::V2(msg) => OpenChannelMessage::V2(msg.clone()),
7972
7980
},
7973
7981
ticks_remaining: UNACCEPTED_INBOUND_CHANNEL_AGE_LIMIT_TICKS,
@@ -8000,6 +8008,7 @@ where
8000
8008
};
8001
8009
(ChannelPhase::UnfundedInboundV1(channel), message_send_event)
8002
8010
},
8011
+ #[cfg(dual_funding)]
8003
8012
OpenChannelMessageRef::V2(msg) => {
8004
8013
let channel = InboundV2Channel::new(&self.fee_estimator, &self.entropy_source,
8005
8014
&self.signer_provider, self.get_our_node_id(), *counterparty_node_id,
@@ -11273,6 +11282,7 @@ where
11273
11282
// Note that we never need to persist the updated ChannelManager for an inbound
11274
11283
// open_channel message - pre-funded channels are never written so there should be no
11275
11284
// change to the contents.
11285
+ #[cfg(dual_funding)]
11276
11286
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
11277
11287
let res = self.internal_open_channel(&counterparty_node_id, OpenChannelMessageRef::V2(msg));
11278
11288
let persist = match &res {
@@ -11285,6 +11295,10 @@ where
11285
11295
let _ = handle_error!(self, res, counterparty_node_id);
11286
11296
persist
11287
11297
});
11298
+ #[cfg(not(dual_funding))]
11299
+ let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
11300
+ "Dual-funded channels not supported".to_owned(),
11301
+ msg.common_fields.temporary_channel_id.clone())), counterparty_node_id);
11288
11302
}
11289
11303
11290
11304
fn handle_accept_channel(&self, counterparty_node_id: PublicKey, msg: &msgs::AcceptChannel) {
0 commit comments