Skip to content

Commit b7267a9

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 7207f36 commit b7267a9

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
@@ -61,7 +61,6 @@ check-cfg = [
6161
"cfg(taproot)",
6262
"cfg(async_signing)",
6363
"cfg(require_route_graph_test)",
64-
"cfg(dual_funding)",
6564
"cfg(splicing)",
6665
"cfg(async_payments)",
6766
]

ci/ci-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
161161
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
162162
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
163163
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
164-
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
165-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
166164
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
167165
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
168166
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
@@ -1120,9 +1120,7 @@ impl_writeable_tlv_based!(PendingChannelMonitorUpdate, {
11201120
pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
11211121
UnfundedOutboundV1(OutboundV1Channel<SP>),
11221122
UnfundedInboundV1(InboundV1Channel<SP>),
1123-
#[cfg(any(dual_funding, splicing))]
11241123
UnfundedOutboundV2(OutboundV2Channel<SP>),
1125-
#[cfg(any(dual_funding, splicing))]
11261124
UnfundedInboundV2(InboundV2Channel<SP>),
11271125
Funded(Channel<SP>),
11281126
}
@@ -1136,9 +1134,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11361134
ChannelPhase::Funded(chan) => &chan.context,
11371135
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
11381136
ChannelPhase::UnfundedInboundV1(chan) => &chan.context,
1139-
#[cfg(any(dual_funding, splicing))]
11401137
ChannelPhase::UnfundedOutboundV2(chan) => &chan.context,
1141-
#[cfg(any(dual_funding, splicing))]
11421138
ChannelPhase::UnfundedInboundV2(chan) => &chan.context,
11431139
}
11441140
}
@@ -1148,9 +1144,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11481144
ChannelPhase::Funded(ref mut chan) => &mut chan.context,
11491145
ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context,
11501146
ChannelPhase::UnfundedInboundV1(ref mut chan) => &mut chan.context,
1151-
#[cfg(any(dual_funding, splicing))]
11521147
ChannelPhase::UnfundedOutboundV2(ref mut chan) => &mut chan.context,
1153-
#[cfg(any(dual_funding, splicing))]
11541148
ChannelPhase::UnfundedInboundV2(ref mut chan) => &mut chan.context,
11551149
}
11561150
}
@@ -3816,15 +3810,13 @@ pub(crate) fn get_legacy_default_holder_selected_channel_reserve_satoshis(channe
38163810
///
38173811
/// This is used both for outbound and inbound channels and has lower bound
38183812
/// of `dust_limit_satoshis`.
3819-
#[cfg(any(dual_funding, splicing))]
38203813
fn get_v2_channel_reserve_satoshis(channel_value_satoshis: u64, dust_limit_satoshis: u64) -> u64 {
38213814
// Fixed at 1% of channel value by spec.
38223815
let (q, _) = channel_value_satoshis.overflowing_div(100);
38233816
cmp::min(channel_value_satoshis, cmp::max(q, dust_limit_satoshis))
38243817
}
38253818

38263819
/// Context for dual-funded channels.
3827-
#[cfg(any(dual_funding, splicing))]
38283820
pub(super) struct DualFundingChannelContext {
38293821
/// The amount in satoshis we will be contributing to the channel.
38303822
pub our_funding_satoshis: u64,
@@ -3841,7 +3833,6 @@ pub(super) struct DualFundingChannelContext {
38413833
// Counterparty designates channel data owned by the another channel participant entity.
38423834
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
38433835
pub context: ChannelContext<SP>,
3844-
#[cfg(any(dual_funding, splicing))]
38453836
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
38463837
}
38473838

@@ -8021,7 +8012,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
80218012

80228013
let mut channel = Channel {
80238014
context: self.context,
8024-
#[cfg(any(dual_funding, splicing))]
80258015
dual_funding_channel_context: None,
80268016
};
80278017

@@ -8256,7 +8246,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82568246
// `ChannelMonitor`.
82578247
let mut channel = Channel {
82588248
context: self.context,
8259-
#[cfg(any(dual_funding, splicing))]
82608249
dual_funding_channel_context: None,
82618250
};
82628251
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8267,15 +8256,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82678256
}
82688257

82698258
// A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8270-
#[cfg(any(dual_funding, splicing))]
82718259
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
82728260
pub context: ChannelContext<SP>,
82738261
pub unfunded_context: UnfundedChannelContext,
8274-
#[cfg(any(dual_funding, splicing))]
82758262
pub dual_funding_context: DualFundingChannelContext,
82768263
}
82778264

8278-
#[cfg(any(dual_funding, splicing))]
82798265
impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
82808266
pub fn new<ES: Deref, F: Deref, L: Deref>(
82818267
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
@@ -8395,14 +8381,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
83958381
}
83968382

83978383
// A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8398-
#[cfg(any(dual_funding, splicing))]
83998384
pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
84008385
pub context: ChannelContext<SP>,
84018386
pub unfunded_context: UnfundedChannelContext,
84028387
pub dual_funding_context: DualFundingChannelContext,
84038388
}
84048389

8405-
#[cfg(any(dual_funding, splicing))]
84068390
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
84078391
/// Creates a new dual-funded channel from a remote side's request for one.
84088392
/// Assumes chain_hash has already been checked and corresponds with what we expect!
@@ -9613,7 +9597,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
96139597
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
96149598
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
96159599
},
9616-
#[cfg(any(dual_funding, splicing))]
96179600
dual_funding_channel_context: None,
96189601
})
96199602
}

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,9 +1182,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
11821182
match phase {
11831183
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
11841184
ChannelPhase::UnfundedInboundV1(_) => false,
1185-
#[cfg(any(dual_funding, splicing))]
11861185
ChannelPhase::UnfundedOutboundV2(_) => true,
1187-
#[cfg(any(dual_funding, splicing))]
11881186
ChannelPhase::UnfundedInboundV2(_) => false,
11891187
}
11901188
)
@@ -2813,11 +2811,9 @@ macro_rules! convert_chan_phase_err {
28132811
ChannelPhase::UnfundedInboundV1(channel) => {
28142812
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
28152813
},
2816-
#[cfg(any(dual_funding, splicing))]
28172814
ChannelPhase::UnfundedOutboundV2(channel) => {
28182815
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
28192816
},
2820-
#[cfg(any(dual_funding, splicing))]
28212817
ChannelPhase::UnfundedInboundV2(channel) => {
28222818
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
28232819
},
@@ -3731,13 +3727,7 @@ where
37313727
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
37323728
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
37333729
},
3734-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
3735-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
3736-
// Unfunded channel has no update
3737-
(None, chan_phase.context().get_counterparty_node_id())
3738-
},
3739-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
3740-
#[cfg(any(dual_funding, splicing))]
3730+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
37413731
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
37423732
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
37433733
// Unfunded channel has no update
@@ -6261,12 +6251,10 @@ where
62616251
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
62626252
pending_msg_events, counterparty_node_id)
62636253
},
6264-
#[cfg(any(dual_funding, splicing))]
62656254
ChannelPhase::UnfundedInboundV2(chan) => {
62666255
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
62676256
pending_msg_events, counterparty_node_id)
62686257
},
6269-
#[cfg(any(dual_funding, splicing))]
62706258
ChannelPhase::UnfundedOutboundV2(chan) => {
62716259
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
62726260
pending_msg_events, counterparty_node_id)
@@ -7582,8 +7570,6 @@ where
75827570
num_unfunded_channels += 1;
75837571
}
75847572
},
7585-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7586-
#[cfg(any(dual_funding, splicing))]
75877573
ChannelPhase::UnfundedInboundV2(chan) => {
75887574
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
75897575
// included in the unfunded count.
@@ -7592,16 +7578,10 @@ where
75927578
num_unfunded_channels += 1;
75937579
}
75947580
},
7595-
ChannelPhase::UnfundedOutboundV1(_) => {
7581+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
75967582
// Outbound channels don't contribute to the unfunded count in the DoS context.
75977583
continue;
75987584
},
7599-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7600-
#[cfg(any(dual_funding, splicing))]
7601-
ChannelPhase::UnfundedOutboundV2(_) => {
7602-
// Outbound channels don't contribute to the unfunded count in the DoS context.
7603-
continue;
7604-
}
76057585
}
76067586
}
76077587
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -8020,21 +8000,14 @@ where
80208000
peer_state_lock, peer_state, per_peer_state, chan);
80218001
}
80228002
},
8023-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
8003+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
8004+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
80248005
let context = phase.context_mut();
80258006
let logger = WithChannelContext::from(&self.logger, context, None);
80268007
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
80278008
let mut chan = remove_channel_phase!(self, chan_phase_entry);
80288009
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
80298010
},
8030-
// TODO(dual_funding): Combine this match arm with above.
8031-
#[cfg(any(dual_funding, splicing))]
8032-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
8033-
let context = phase.context_mut();
8034-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
8035-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
8036-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
8037-
},
80388011
}
80398012
} else {
80408013
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))
@@ -8955,7 +8928,7 @@ where
89558928
}
89568929
None
89578930
}
8958-
ChannelPhase::UnfundedInboundV1(_) => None,
8931+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => None,
89598932
}
89608933
};
89618934

@@ -10183,9 +10156,7 @@ where
1018310156
peer_state.channel_by_id.retain(|_, phase| {
1018410157
match phase {
1018510158
// Retain unfunded channels.
10186-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
10187-
// TODO(dual_funding): Combine this match arm with above.
10188-
#[cfg(any(dual_funding, splicing))]
10159+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
1018910160
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
1019010161
ChannelPhase::Funded(channel) => {
1019110162
let res = f(channel);
@@ -10668,11 +10639,9 @@ where
1066810639
ChannelPhase::UnfundedInboundV1(chan) => {
1066910640
&mut chan.context
1067010641
},
10671-
#[cfg(any(dual_funding, splicing))]
1067210642
ChannelPhase::UnfundedOutboundV2(chan) => {
1067310643
&mut chan.context
1067410644
},
10675-
#[cfg(any(dual_funding, splicing))]
1067610645
ChannelPhase::UnfundedInboundV2(chan) => {
1067710646
&mut chan.context
1067810647
},
@@ -10833,30 +10802,19 @@ where
1083310802
});
1083410803
}
1083510804

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

10845-
ChannelPhase::UnfundedInboundV1(_) => {
10812+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1084610813
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1084710814
// they are not persisted and won't be recovered after a crash.
1084810815
// Therefore, they shouldn't exist at this point.
1084910816
debug_assert!(false);
1085010817
}
10851-
10852-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10853-
#[cfg(any(dual_funding, splicing))]
10854-
ChannelPhase::UnfundedInboundV2(channel) => {
10855-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10856-
// they are not persisted and won't be recovered after a crash.
10857-
// Therefore, they shouldn't exist at this point.
10858-
debug_assert!(false);
10859-
},
1086010818
}
1086110819
}
1086210820
}
@@ -10953,7 +10911,6 @@ where
1095310911
return;
1095410912
}
1095510913
},
10956-
#[cfg(any(dual_funding, splicing))]
1095710914
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1095810915
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1095910916
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10963,9 +10920,7 @@ where
1096310920
return;
1096410921
}
1096510922
},
10966-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10967-
#[cfg(any(dual_funding, splicing))]
10968-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10923+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1096910924
}
1097010925
}
1097110926

lightning/src/ln/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ mod async_signer_tests;
9696
#[cfg(test)]
9797
#[allow(unused_mut)]
9898
mod offers_tests;
99-
#[allow(dead_code)] // TODO(dual_funding): Exchange for dual_funding cfg
10099
pub(crate) mod interactivetxs;
101100

102101
pub use self::peer_channel_encryptor::LN_MAX_MSG_LEN;

0 commit comments

Comments
 (0)