@@ -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(any(dual_funding, splicing))]
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))]
@@ -1391,11 +1393,13 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
1391
1393
#[derive(Clone)]
1392
1394
pub(super) enum OpenChannelMessage {
1393
1395
V1(msgs::OpenChannel),
1396
+ #[cfg(dual_funding)]
1394
1397
V2(msgs::OpenChannelV2),
1395
1398
}
1396
1399
1397
1400
pub(super) enum OpenChannelMessageRef<'a> {
1398
1401
V1(&'a msgs::OpenChannel),
1402
+ #[cfg(dual_funding)]
1399
1403
V2(&'a msgs::OpenChannelV2),
1400
1404
}
1401
1405
@@ -7651,8 +7655,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
7651
7655
7652
7656
fn do_accept_inbound_channel(
7653
7657
&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,
7656
7660
) -> Result<(), APIError> {
7657
7661
let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id), None);
7658
7662
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/
7696
7700
(*temporary_channel_id, ChannelPhase::UnfundedInboundV1(channel), message_send_event)
7697
7701
})
7698
7702
},
7703
+ #[cfg(dual_funding)]
7699
7704
OpenChannelMessage::V2(open_channel_msg) => {
7700
7705
InboundV2Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
7701
7706
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,
7703
7708
&self.default_configuration, best_block_height, &self.logger
7704
7709
).map_err(|_| MsgHandleErrInternal::from_chan_no_close(
7705
7710
ChannelError::Close(
@@ -7852,6 +7857,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
7852
7857
fn internal_open_channel(&self, counterparty_node_id: &PublicKey, msg: OpenChannelMessageRef<'_>) -> Result<(), MsgHandleErrInternal> {
7853
7858
let common_fields = match msg {
7854
7859
OpenChannelMessageRef::V1(msg) => &msg.common_fields,
7860
+ #[cfg(dual_funding)]
7855
7861
OpenChannelMessageRef::V2(msg) => &msg.common_fields,
7856
7862
};
7857
7863
@@ -7929,6 +7935,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
7929
7935
funding_satoshis: common_fields.funding_satoshis,
7930
7936
channel_negotiation_type: match msg {
7931
7937
OpenChannelMessageRef::V1(msg) => InboundChannelFunds::PushMsat(msg.push_msat),
7938
+ #[cfg(dual_funding)]
7932
7939
OpenChannelMessageRef::V2(_) => InboundChannelFunds::DualFunded,
7933
7940
},
7934
7941
channel_type,
@@ -7938,6 +7945,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
7938
7945
peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {
7939
7946
open_channel_msg: match msg {
7940
7947
OpenChannelMessageRef::V1(msg) => OpenChannelMessage::V1(msg.clone()),
7948
+ #[cfg(dual_funding)]
7941
7949
OpenChannelMessageRef::V2(msg) => OpenChannelMessage::V2(msg.clone()),
7942
7950
},
7943
7951
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/
7973
7981
});
7974
7982
(ChannelPhase::UnfundedInboundV1(channel), message_send_event)
7975
7983
},
7984
+ #[cfg(dual_funding)]
7976
7985
OpenChannelMessageRef::V2(msg) => {
7977
7986
let channel = InboundV2Channel::new(&self.fee_estimator, &self.entropy_source,
7978
7987
&self.signer_provider, self.get_our_node_id(), *counterparty_node_id,
@@ -11271,6 +11280,7 @@ where
11271
11280
// Note that we never need to persist the updated ChannelManager for an inbound
11272
11281
// open_channel message - pre-funded channels are never written so there should be no
11273
11282
// change to the contents.
11283
+ #[cfg(dual_funding)]
11274
11284
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
11275
11285
let res = self.internal_open_channel(&counterparty_node_id, OpenChannelMessageRef::V2(msg));
11276
11286
let persist = match &res {
@@ -11283,6 +11293,10 @@ where
11283
11293
let _ = handle_error!(self, res, counterparty_node_id);
11284
11294
persist
11285
11295
});
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);
11286
11300
}
11287
11301
11288
11302
fn handle_accept_channel(&self, counterparty_node_id: PublicKey, msg: &msgs::AcceptChannel) {
@@ -12334,6 +12348,7 @@ pub fn provided_init_features(config: &UserConfig) -> InitFeatures {
12334
12348
if config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx {
12335
12349
features.set_anchors_zero_fee_htlc_tx_optional();
12336
12350
}
12351
+ #[cfg(dual_funding)]
12337
12352
features.set_dual_fund_optional();
12338
12353
features
12339
12354
}
0 commit comments