Skip to content

Commit 7e23afc

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 899d5f5 commit 7e23afc

File tree

5 files changed

+7
-75
lines changed

5 files changed

+7
-75
lines changed

Cargo.toml

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

ci/ci-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
166166
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
167167
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
168168
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
169-
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
170-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
171169
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
172170
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
173171
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

@@ -8032,7 +8023,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
80328023

80338024
let mut channel = Channel {
80348025
context: self.context,
8035-
#[cfg(any(dual_funding, splicing))]
80368026
dual_funding_channel_context: None,
80378027
};
80388028

@@ -8262,7 +8252,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82628252
// `ChannelMonitor`.
82638253
let mut channel = Channel {
82648254
context: self.context,
8265-
#[cfg(any(dual_funding, splicing))]
82668255
dual_funding_channel_context: None,
82678256
};
82688257
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8273,15 +8262,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82738262
}
82748263

82758264
// A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8276-
#[cfg(any(dual_funding, splicing))]
82778265
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
82788266
pub context: ChannelContext<SP>,
82798267
pub unfunded_context: UnfundedChannelContext,
8280-
#[cfg(any(dual_funding, splicing))]
82818268
pub dual_funding_context: DualFundingChannelContext,
82828269
}
82838270

8284-
#[cfg(any(dual_funding, splicing))]
82858271
impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
82868272
pub fn new<ES: Deref, F: Deref, L: Deref>(
82878273
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
@@ -8401,14 +8387,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
84018387
}
84028388

84038389
// A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8404-
#[cfg(any(dual_funding, splicing))]
84058390
pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
84068391
pub context: ChannelContext<SP>,
84078392
pub unfunded_context: UnfundedChannelContext,
84088393
pub dual_funding_context: DualFundingChannelContext,
84098394
}
84108395

8411-
#[cfg(any(dual_funding, splicing))]
84128396
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
84138397
/// Creates a new dual-funded channel from a remote side's request for one.
84148398
/// Assumes chain_hash has already been checked and corresponds with what we expect!
@@ -9619,7 +9603,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
96199603
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
96209604
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
96219605
},
9622-
#[cfg(any(dual_funding, splicing))]
96239606
dual_funding_channel_context: None,
96249607
})
96259608
}

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
13361336
match phase {
13371337
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
13381338
ChannelPhase::UnfundedInboundV1(_) => false,
1339-
#[cfg(any(dual_funding, splicing))]
13401339
ChannelPhase::UnfundedOutboundV2(_) => true,
1341-
#[cfg(any(dual_funding, splicing))]
13421340
ChannelPhase::UnfundedInboundV2(_) => false,
13431341
}
13441342
)
@@ -3009,11 +3007,9 @@ macro_rules! convert_chan_phase_err {
30093007
ChannelPhase::UnfundedInboundV1(channel) => {
30103008
convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, UNFUNDED_CHANNEL)
30113009
},
3012-
#[cfg(any(dual_funding, splicing))]
30133010
ChannelPhase::UnfundedOutboundV2(channel) => {
30143011
convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, UNFUNDED_CHANNEL)
30153012
},
3016-
#[cfg(any(dual_funding, splicing))]
30173013
ChannelPhase::UnfundedInboundV2(channel) => {
30183014
convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, UNFUNDED_CHANNEL)
30193015
},
@@ -3997,13 +3993,7 @@ where
39973993
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
39983994
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
39993995
},
4000-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
4001-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
4002-
// Unfunded channel has no update
4003-
(None, chan_phase.context().get_counterparty_node_id())
4004-
},
4005-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
4006-
#[cfg(any(dual_funding, splicing))]
3996+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
40073997
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
40083998
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
40093999
// Unfunded channel has no update
@@ -6482,11 +6472,9 @@ where
64826472
ChannelPhase::UnfundedOutboundV1(chan) => {
64836473
process_unfunded_channel_tick!(peer_state, chan, pending_msg_events)
64846474
},
6485-
#[cfg(any(dual_funding, splicing))]
64866475
ChannelPhase::UnfundedInboundV2(chan) => {
64876476
process_unfunded_channel_tick!(peer_state, chan, pending_msg_events)
64886477
},
6489-
#[cfg(any(dual_funding, splicing))]
64906478
ChannelPhase::UnfundedOutboundV2(chan) => {
64916479
process_unfunded_channel_tick!(peer_state, chan, pending_msg_events)
64926480
},
@@ -7772,8 +7760,6 @@ where
77727760
num_unfunded_channels += 1;
77737761
}
77747762
},
7775-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7776-
#[cfg(any(dual_funding, splicing))]
77777763
ChannelPhase::UnfundedInboundV2(chan) => {
77787764
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
77797765
// included in the unfunded count.
@@ -7782,16 +7768,10 @@ where
77827768
num_unfunded_channels += 1;
77837769
}
77847770
},
7785-
ChannelPhase::UnfundedOutboundV1(_) => {
7771+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
77867772
// Outbound channels don't contribute to the unfunded count in the DoS context.
77877773
continue;
77887774
},
7789-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7790-
#[cfg(any(dual_funding, splicing))]
7791-
ChannelPhase::UnfundedOutboundV2(_) => {
7792-
// Outbound channels don't contribute to the unfunded count in the DoS context.
7793-
continue;
7794-
}
77957775
}
77967776
}
77977777
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -8210,17 +8190,8 @@ where
82108190
peer_state_lock, peer_state, per_peer_state, chan);
82118191
}
82128192
},
8213-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
8214-
let context = phase.context_mut();
8215-
let logger = WithChannelContext::from(&self.logger, context, None);
8216-
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
8217-
let mut chan = remove_channel_phase!(self, peer_state, chan_phase_entry);
8218-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
8219-
},
8220-
// TODO(dual_funding): Combine this match arm with above.
8221-
#[cfg(any(dual_funding, splicing))]
8193+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
82228194
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
8223-
let context = phase.context_mut();
82248195
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
82258196
let mut chan = remove_channel_phase!(self, peer_state, chan_phase_entry);
82268197
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
@@ -9145,7 +9116,7 @@ where
91459116
}
91469117
None
91479118
}
9148-
ChannelPhase::UnfundedInboundV1(_) => None,
9119+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => None,
91499120
}
91509121
};
91519122

@@ -10601,9 +10572,7 @@ where
1060110572
peer_state.channel_by_id.retain(|_, phase| {
1060210573
match phase {
1060310574
// Retain unfunded channels.
10604-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
10605-
// TODO(dual_funding): Combine this match arm with above.
10606-
#[cfg(any(dual_funding, splicing))]
10575+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
1060710576
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
1060810577
ChannelPhase::Funded(channel) => {
1060910578
let res = f(channel);
@@ -11111,11 +11080,9 @@ where
1111111080
ChannelPhase::UnfundedInboundV1(chan) => {
1111211081
&mut chan.context
1111311082
},
11114-
#[cfg(any(dual_funding, splicing))]
1111511083
ChannelPhase::UnfundedOutboundV2(chan) => {
1111611084
&mut chan.context
1111711085
},
11118-
#[cfg(any(dual_funding, splicing))]
1111911086
ChannelPhase::UnfundedInboundV2(chan) => {
1112011087
&mut chan.context
1112111088
},
@@ -11277,30 +11244,19 @@ where
1127711244
});
1127811245
}
1127911246

11280-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
11281-
#[cfg(any(dual_funding, splicing))]
1128211247
ChannelPhase::UnfundedOutboundV2(chan) => {
1128311248
pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
1128411249
node_id: chan.context.get_counterparty_node_id(),
1128511250
msg: chan.get_open_channel_v2(self.chain_hash),
1128611251
});
1128711252
},
1128811253

11289-
ChannelPhase::UnfundedInboundV1(_) => {
11254+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1129011255
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1129111256
// they are not persisted and won't be recovered after a crash.
1129211257
// Therefore, they shouldn't exist at this point.
1129311258
debug_assert!(false);
1129411259
}
11295-
11296-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
11297-
#[cfg(any(dual_funding, splicing))]
11298-
ChannelPhase::UnfundedInboundV2(channel) => {
11299-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
11300-
// they are not persisted and won't be recovered after a crash.
11301-
// Therefore, they shouldn't exist at this point.
11302-
debug_assert!(false);
11303-
},
1130411260
}
1130511261
}
1130611262
}
@@ -11397,7 +11353,6 @@ where
1139711353
return;
1139811354
}
1139911355
},
11400-
#[cfg(any(dual_funding, splicing))]
1140111356
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1140211357
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1140311358
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -11407,9 +11362,7 @@ where
1140711362
return;
1140811363
}
1140911364
},
11410-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
11411-
#[cfg(any(dual_funding, splicing))]
11412-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
11365+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1141311366
}
1141411367
}
1141511368

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)