Skip to content

Commit a499641

Browse files
committed
Remove dual_funding cfg attributes
We'll only gate public API related to contributing toward an inbound or opening a dual funded channel.
1 parent 4013828 commit a499641

File tree

5 files changed

+8
-74
lines changed

5 files changed

+8
-74
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ check-cfg = [
6262
"cfg(taproot)",
6363
"cfg(async_signing)",
6464
"cfg(require_route_graph_test)",
65-
"cfg(dual_funding)",
6665
"cfg(splicing)",
6766
"cfg(async_payments)",
6867
]

ci/ci-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
162162
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
163163
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
164164
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
165-
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
166-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
167165
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
168166
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
169167
RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning

lightning/src/ln/channel.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,7 @@ impl_writeable_tlv_based!(PendingChannelMonitorUpdate, {
11211121
pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
11221122
UnfundedOutboundV1(OutboundV1Channel<SP>),
11231123
UnfundedInboundV1(InboundV1Channel<SP>),
1124-
#[cfg(any(dual_funding, splicing))]
11251124
UnfundedOutboundV2(OutboundV2Channel<SP>),
1126-
#[cfg(any(dual_funding, splicing))]
11271125
UnfundedInboundV2(InboundV2Channel<SP>),
11281126
Funded(Channel<SP>),
11291127
}
@@ -1137,9 +1135,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11371135
ChannelPhase::Funded(chan) => &chan.context,
11381136
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
11391137
ChannelPhase::UnfundedInboundV1(chan) => &chan.context,
1140-
#[cfg(any(dual_funding, splicing))]
11411138
ChannelPhase::UnfundedOutboundV2(chan) => &chan.context,
1142-
#[cfg(any(dual_funding, splicing))]
11431139
ChannelPhase::UnfundedInboundV2(chan) => &chan.context,
11441140
}
11451141
}
@@ -1149,9 +1145,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11491145
ChannelPhase::Funded(ref mut chan) => &mut chan.context,
11501146
ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context,
11511147
ChannelPhase::UnfundedInboundV1(ref mut chan) => &mut chan.context,
1152-
#[cfg(any(dual_funding, splicing))]
11531148
ChannelPhase::UnfundedOutboundV2(ref mut chan) => &mut chan.context,
1154-
#[cfg(any(dual_funding, splicing))]
11551149
ChannelPhase::UnfundedInboundV2(ref mut chan) => &mut chan.context,
11561150
}
11571151
}
@@ -3822,15 +3816,13 @@ pub(crate) fn get_legacy_default_holder_selected_channel_reserve_satoshis(channe
38223816
///
38233817
/// This is used both for outbound and inbound channels and has lower bound
38243818
/// of `dust_limit_satoshis`.
3825-
#[cfg(any(dual_funding, splicing))]
38263819
fn get_v2_channel_reserve_satoshis(channel_value_satoshis: u64, dust_limit_satoshis: u64) -> u64 {
38273820
// Fixed at 1% of channel value by spec.
38283821
let (q, _) = channel_value_satoshis.overflowing_div(100);
38293822
cmp::min(channel_value_satoshis, cmp::max(q, dust_limit_satoshis))
38303823
}
38313824

38323825
/// Context for dual-funded channels.
3833-
#[cfg(any(dual_funding, splicing))]
38343826
pub(super) struct DualFundingChannelContext {
38353827
/// The amount in satoshis we will be contributing to the channel.
38363828
pub our_funding_satoshis: u64,
@@ -3847,7 +3839,6 @@ pub(super) struct DualFundingChannelContext {
38473839
// Counterparty designates channel data owned by the another channel participant entity.
38483840
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
38493841
pub context: ChannelContext<SP>,
3850-
#[cfg(any(dual_funding, splicing))]
38513842
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
38523843
}
38533844

@@ -8017,7 +8008,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
80178008

80188009
let mut channel = Channel {
80198010
context: self.context,
8020-
#[cfg(any(dual_funding, splicing))]
80218011
dual_funding_channel_context: None,
80228012
};
80238013

@@ -8247,7 +8237,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82478237
// `ChannelMonitor`.
82488238
let mut channel = Channel {
82498239
context: self.context,
8250-
#[cfg(any(dual_funding, splicing))]
82518240
dual_funding_channel_context: None,
82528241
};
82538242
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8258,15 +8247,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82588247
}
82598248

82608249
// A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8261-
#[cfg(any(dual_funding, splicing))]
82628250
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
82638251
pub context: ChannelContext<SP>,
82648252
pub unfunded_context: UnfundedChannelContext,
8265-
#[cfg(any(dual_funding, splicing))]
82668253
pub dual_funding_context: DualFundingChannelContext,
82678254
}
82688255

8269-
#[cfg(any(dual_funding, splicing))]
82708256
impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
82718257
pub fn new<ES: Deref, F: Deref, L: Deref>(
82728258
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
@@ -8386,14 +8372,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
83868372
}
83878373

83888374
// A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8389-
#[cfg(any(dual_funding, splicing))]
83908375
pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
83918376
pub context: ChannelContext<SP>,
83928377
pub unfunded_context: UnfundedChannelContext,
83938378
pub dual_funding_context: DualFundingChannelContext,
83948379
}
83958380

8396-
#[cfg(any(dual_funding, splicing))]
83978381
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
83988382
/// Creates a new dual-funded channel from a remote side's request for one.
83998383
/// Assumes chain_hash has already been checked and corresponds with what we expect!
@@ -9604,7 +9588,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
96049588
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
96059589
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
96069590
},
9607-
#[cfg(any(dual_funding, splicing))]
96089591
dual_funding_channel_context: None,
96099592
})
96109593
}

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
11831183
match phase {
11841184
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
11851185
ChannelPhase::UnfundedInboundV1(_) => false,
1186-
#[cfg(any(dual_funding, splicing))]
11871186
ChannelPhase::UnfundedOutboundV2(_) => true,
1188-
#[cfg(any(dual_funding, splicing))]
11891187
ChannelPhase::UnfundedInboundV2(_) => false,
11901188
}
11911189
)
@@ -2814,11 +2812,9 @@ macro_rules! convert_chan_phase_err {
28142812
ChannelPhase::UnfundedInboundV1(channel) => {
28152813
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
28162814
},
2817-
#[cfg(any(dual_funding, splicing))]
28182815
ChannelPhase::UnfundedOutboundV2(channel) => {
28192816
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
28202817
},
2821-
#[cfg(any(dual_funding, splicing))]
28222818
ChannelPhase::UnfundedInboundV2(channel) => {
28232819
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
28242820
},
@@ -3732,13 +3728,7 @@ where
37323728
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
37333729
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
37343730
},
3735-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
3736-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
3737-
// Unfunded channel has no update
3738-
(None, chan_phase.context().get_counterparty_node_id())
3739-
},
3740-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
3741-
#[cfg(any(dual_funding, splicing))]
3731+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
37423732
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
37433733
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
37443734
// Unfunded channel has no update
@@ -6262,12 +6252,10 @@ where
62626252
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
62636253
pending_msg_events, counterparty_node_id)
62646254
},
6265-
#[cfg(any(dual_funding, splicing))]
62666255
ChannelPhase::UnfundedInboundV2(chan) => {
62676256
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
62686257
pending_msg_events, counterparty_node_id)
62696258
},
6270-
#[cfg(any(dual_funding, splicing))]
62716259
ChannelPhase::UnfundedOutboundV2(chan) => {
62726260
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
62736261
pending_msg_events, counterparty_node_id)
@@ -7583,8 +7571,6 @@ where
75837571
num_unfunded_channels += 1;
75847572
}
75857573
},
7586-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7587-
#[cfg(any(dual_funding, splicing))]
75887574
ChannelPhase::UnfundedInboundV2(chan) => {
75897575
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
75907576
// included in the unfunded count.
@@ -7593,16 +7579,10 @@ where
75937579
num_unfunded_channels += 1;
75947580
}
75957581
},
7596-
ChannelPhase::UnfundedOutboundV1(_) => {
7582+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
75977583
// Outbound channels don't contribute to the unfunded count in the DoS context.
75987584
continue;
75997585
},
7600-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7601-
#[cfg(any(dual_funding, splicing))]
7602-
ChannelPhase::UnfundedOutboundV2(_) => {
7603-
// Outbound channels don't contribute to the unfunded count in the DoS context.
7604-
continue;
7605-
}
76067586
}
76077587
}
76087588
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -8021,21 +8001,14 @@ where
80218001
peer_state_lock, peer_state, per_peer_state, chan);
80228002
}
80238003
},
8024-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
8004+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
8005+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
80258006
let context = phase.context_mut();
80268007
let logger = WithChannelContext::from(&self.logger, context, None);
80278008
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
80288009
let mut chan = remove_channel_phase!(self, chan_phase_entry);
80298010
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
80308011
},
8031-
// TODO(dual_funding): Combine this match arm with above.
8032-
#[cfg(any(dual_funding, splicing))]
8033-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
8034-
let context = phase.context_mut();
8035-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
8036-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
8037-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
8038-
},
80398012
}
80408013
} else {
80418014
return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))
@@ -8956,7 +8929,7 @@ where
89568929
}
89578930
None
89588931
}
8959-
ChannelPhase::UnfundedInboundV1(_) => None,
8932+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => None,
89608933
}
89618934
};
89628935

@@ -10184,9 +10157,7 @@ where
1018410157
peer_state.channel_by_id.retain(|_, phase| {
1018510158
match phase {
1018610159
// Retain unfunded channels.
10187-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
10188-
// TODO(dual_funding): Combine this match arm with above.
10189-
#[cfg(any(dual_funding, splicing))]
10160+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
1019010161
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
1019110162
ChannelPhase::Funded(channel) => {
1019210163
let res = f(channel);
@@ -10669,11 +10640,9 @@ where
1066910640
ChannelPhase::UnfundedInboundV1(chan) => {
1067010641
&mut chan.context
1067110642
},
10672-
#[cfg(any(dual_funding, splicing))]
1067310643
ChannelPhase::UnfundedOutboundV2(chan) => {
1067410644
&mut chan.context
1067510645
},
10676-
#[cfg(any(dual_funding, splicing))]
1067710646
ChannelPhase::UnfundedInboundV2(chan) => {
1067810647
&mut chan.context
1067910648
},
@@ -10834,30 +10803,19 @@ where
1083410803
});
1083510804
}
1083610805

10837-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10838-
#[cfg(any(dual_funding, splicing))]
1083910806
ChannelPhase::UnfundedOutboundV2(chan) => {
1084010807
pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
1084110808
node_id: chan.context.get_counterparty_node_id(),
1084210809
msg: chan.get_open_channel_v2(self.chain_hash),
1084310810
});
1084410811
},
1084510812

10846-
ChannelPhase::UnfundedInboundV1(_) => {
10813+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1084710814
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1084810815
// they are not persisted and won't be recovered after a crash.
1084910816
// Therefore, they shouldn't exist at this point.
1085010817
debug_assert!(false);
1085110818
}
10852-
10853-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10854-
#[cfg(any(dual_funding, splicing))]
10855-
ChannelPhase::UnfundedInboundV2(channel) => {
10856-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10857-
// they are not persisted and won't be recovered after a crash.
10858-
// Therefore, they shouldn't exist at this point.
10859-
debug_assert!(false);
10860-
},
1086110819
}
1086210820
}
1086310821
}
@@ -10954,7 +10912,6 @@ where
1095410912
return;
1095510913
}
1095610914
},
10957-
#[cfg(any(dual_funding, splicing))]
1095810915
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1095910916
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1096010917
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10964,9 +10921,7 @@ where
1096410921
return;
1096510922
}
1096610923
},
10967-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10968-
#[cfg(any(dual_funding, splicing))]
10969-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10924+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1097010925
}
1097110926
}
1097210927

lightning/src/ln/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ mod async_signer_tests;
8888
#[cfg(test)]
8989
#[allow(unused_mut)]
9090
mod offers_tests;
91-
#[allow(dead_code)] // TODO(dual_funding): Exchange for dual_funding cfg
9291
pub(crate) mod interactivetxs;
9392

9493
pub use self::peer_channel_encryptor::LN_MAX_MSG_LEN;

0 commit comments

Comments
 (0)