Skip to content

Commit fc1d8f9

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 ce2ccc3 commit fc1d8f9

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
@@ -59,7 +59,6 @@ check-cfg = [
5959
"cfg(taproot)",
6060
"cfg(async_signing)",
6161
"cfg(require_route_graph_test)",
62-
"cfg(dual_funding)",
6362
"cfg(splicing)",
6463
"cfg(async_payments)",
6564
]

ci/ci-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
137137
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
138138
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
139139
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
140-
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
141-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
142140
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
143141
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
144142
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
@@ -1119,9 +1119,7 @@ impl_writeable_tlv_based!(PendingChannelMonitorUpdate, {
11191119
pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
11201120
UnfundedOutboundV1(OutboundV1Channel<SP>),
11211121
UnfundedInboundV1(InboundV1Channel<SP>),
1122-
#[cfg(any(dual_funding, splicing))]
11231122
UnfundedOutboundV2(OutboundV2Channel<SP>),
1124-
#[cfg(any(dual_funding, splicing))]
11251123
UnfundedInboundV2(InboundV2Channel<SP>),
11261124
Funded(Channel<SP>),
11271125
}
@@ -1135,9 +1133,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11351133
ChannelPhase::Funded(chan) => &chan.context,
11361134
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
11371135
ChannelPhase::UnfundedInboundV1(chan) => &chan.context,
1138-
#[cfg(any(dual_funding, splicing))]
11391136
ChannelPhase::UnfundedOutboundV2(chan) => &chan.context,
1140-
#[cfg(any(dual_funding, splicing))]
11411137
ChannelPhase::UnfundedInboundV2(chan) => &chan.context,
11421138
}
11431139
}
@@ -1147,9 +1143,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11471143
ChannelPhase::Funded(ref mut chan) => &mut chan.context,
11481144
ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context,
11491145
ChannelPhase::UnfundedInboundV1(ref mut chan) => &mut chan.context,
1150-
#[cfg(any(dual_funding, splicing))]
11511146
ChannelPhase::UnfundedOutboundV2(ref mut chan) => &mut chan.context,
1152-
#[cfg(any(dual_funding, splicing))]
11531147
ChannelPhase::UnfundedInboundV2(ref mut chan) => &mut chan.context,
11541148
}
11551149
}
@@ -3672,15 +3666,13 @@ pub(crate) fn get_legacy_default_holder_selected_channel_reserve_satoshis(channe
36723666
///
36733667
/// This is used both for outbound and inbound channels and has lower bound
36743668
/// of `dust_limit_satoshis`.
3675-
#[cfg(any(dual_funding, splicing))]
36763669
fn get_v2_channel_reserve_satoshis(channel_value_satoshis: u64, dust_limit_satoshis: u64) -> u64 {
36773670
// Fixed at 1% of channel value by spec.
36783671
let (q, _) = channel_value_satoshis.overflowing_div(100);
36793672
cmp::min(channel_value_satoshis, cmp::max(q, dust_limit_satoshis))
36803673
}
36813674

36823675
/// Context for dual-funded channels.
3683-
#[cfg(any(dual_funding, splicing))]
36843676
pub(super) struct DualFundingChannelContext {
36853677
/// The amount in satoshis we will be contributing to the channel.
36863678
pub our_funding_satoshis: u64,
@@ -3697,7 +3689,6 @@ pub(super) struct DualFundingChannelContext {
36973689
// Counterparty designates channel data owned by the another channel participant entity.
36983690
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
36993691
pub context: ChannelContext<SP>,
3700-
#[cfg(any(dual_funding, splicing))]
37013692
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
37023693
}
37033694

@@ -7929,7 +7920,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
79297920

79307921
let mut channel = Channel {
79317922
context: self.context,
7932-
#[cfg(any(dual_funding, splicing))]
79337923
dual_funding_channel_context: None,
79347924
};
79357925

@@ -8227,7 +8217,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82278217
// `ChannelMonitor`.
82288218
let mut channel = Channel {
82298219
context: self.context,
8230-
#[cfg(any(dual_funding, splicing))]
82318220
dual_funding_channel_context: None,
82328221
};
82338222
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8238,15 +8227,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
82388227
}
82398228

82408229
// A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8241-
#[cfg(any(dual_funding, splicing))]
82428230
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
82438231
pub context: ChannelContext<SP>,
82448232
pub unfunded_context: UnfundedChannelContext,
8245-
#[cfg(any(dual_funding, splicing))]
82468233
pub dual_funding_context: DualFundingChannelContext,
82478234
}
82488235

8249-
#[cfg(any(dual_funding, splicing))]
82508236
impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
82518237
pub fn new<ES: Deref, F: Deref, L: Deref>(
82528238
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
@@ -8366,14 +8352,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
83668352
}
83678353

83688354
// A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8369-
#[cfg(any(dual_funding, splicing))]
83708355
pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
83718356
pub context: ChannelContext<SP>,
83728357
pub unfunded_context: UnfundedChannelContext,
83738358
pub dual_funding_context: DualFundingChannelContext,
83748359
}
83758360

8376-
#[cfg(any(dual_funding, splicing))]
83778361
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
83788362
/// Creates a new dual-funded channel from a remote side's request for one.
83798363
/// Assumes chain_hash has already been checked and corresponds with what we expect!
@@ -9584,7 +9568,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
95849568
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
95859569
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
95869570
},
9587-
#[cfg(any(dual_funding, splicing))]
95889571
dual_funding_channel_context: None,
95899572
})
95909573
}

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,9 +1135,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
11351135
match phase {
11361136
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
11371137
ChannelPhase::UnfundedInboundV1(_) => false,
1138-
#[cfg(any(dual_funding, splicing))]
11391138
ChannelPhase::UnfundedOutboundV2(_) => true,
1140-
#[cfg(any(dual_funding, splicing))]
11411139
ChannelPhase::UnfundedInboundV2(_) => false,
11421140
}
11431141
)
@@ -2742,11 +2740,9 @@ macro_rules! convert_chan_phase_err {
27422740
ChannelPhase::UnfundedInboundV1(channel) => {
27432741
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
27442742
},
2745-
#[cfg(any(dual_funding, splicing))]
27462743
ChannelPhase::UnfundedOutboundV2(channel) => {
27472744
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
27482745
},
2749-
#[cfg(any(dual_funding, splicing))]
27502746
ChannelPhase::UnfundedInboundV2(channel) => {
27512747
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
27522748
},
@@ -3656,13 +3652,7 @@ where
36563652
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
36573653
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
36583654
},
3659-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
3660-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
3661-
// Unfunded channel has no update
3662-
(None, chan_phase.context().get_counterparty_node_id())
3663-
},
3664-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
3665-
#[cfg(any(dual_funding, splicing))]
3655+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
36663656
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
36673657
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
36683658
// Unfunded channel has no update
@@ -6181,12 +6171,10 @@ where
61816171
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
61826172
pending_msg_events, counterparty_node_id)
61836173
},
6184-
#[cfg(any(dual_funding, splicing))]
61856174
ChannelPhase::UnfundedInboundV2(chan) => {
61866175
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
61876176
pending_msg_events, counterparty_node_id)
61886177
},
6189-
#[cfg(any(dual_funding, splicing))]
61906178
ChannelPhase::UnfundedOutboundV2(chan) => {
61916179
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
61926180
pending_msg_events, counterparty_node_id)
@@ -7498,8 +7486,6 @@ where
74987486
num_unfunded_channels += 1;
74997487
}
75007488
},
7501-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7502-
#[cfg(any(dual_funding, splicing))]
75037489
ChannelPhase::UnfundedInboundV2(chan) => {
75047490
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
75057491
// included in the unfunded count.
@@ -7508,16 +7494,10 @@ where
75087494
num_unfunded_channels += 1;
75097495
}
75107496
},
7511-
ChannelPhase::UnfundedOutboundV1(_) => {
7497+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
75127498
// Outbound channels don't contribute to the unfunded count in the DoS context.
75137499
continue;
75147500
},
7515-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7516-
#[cfg(any(dual_funding, splicing))]
7517-
ChannelPhase::UnfundedOutboundV2(_) => {
7518-
// Outbound channels don't contribute to the unfunded count in the DoS context.
7519-
continue;
7520-
}
75217501
}
75227502
}
75237503
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -7936,21 +7916,14 @@ where
79367916
peer_state_lock, peer_state, per_peer_state, chan);
79377917
}
79387918
},
7939-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
7919+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
7920+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
79407921
let context = phase.context_mut();
79417922
let logger = WithChannelContext::from(&self.logger, context, None);
79427923
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
79437924
let mut chan = remove_channel_phase!(self, chan_phase_entry);
79447925
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
79457926
},
7946-
// TODO(dual_funding): Combine this match arm with above.
7947-
#[cfg(any(dual_funding, splicing))]
7948-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7949-
let context = phase.context_mut();
7950-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
7951-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
7952-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
7953-
},
79547927
}
79557928
} else {
79567929
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))
@@ -8871,7 +8844,7 @@ where
88718844
}
88728845
None
88738846
}
8874-
ChannelPhase::UnfundedInboundV1(_) => None,
8847+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => None,
88758848
}
88768849
};
88778850

@@ -10093,9 +10066,7 @@ where
1009310066
peer_state.channel_by_id.retain(|_, phase| {
1009410067
match phase {
1009510068
// Retain unfunded channels.
10096-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
10097-
// TODO(dual_funding): Combine this match arm with above.
10098-
#[cfg(any(dual_funding, splicing))]
10069+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
1009910070
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
1010010071
ChannelPhase::Funded(channel) => {
1010110072
let res = f(channel);
@@ -10577,11 +10548,9 @@ where
1057710548
ChannelPhase::UnfundedInboundV1(chan) => {
1057810549
&mut chan.context
1057910550
},
10580-
#[cfg(any(dual_funding, splicing))]
1058110551
ChannelPhase::UnfundedOutboundV2(chan) => {
1058210552
&mut chan.context
1058310553
},
10584-
#[cfg(any(dual_funding, splicing))]
1058510554
ChannelPhase::UnfundedInboundV2(chan) => {
1058610555
&mut chan.context
1058710556
},
@@ -10742,30 +10711,19 @@ where
1074210711
});
1074310712
}
1074410713

10745-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10746-
#[cfg(any(dual_funding, splicing))]
1074710714
ChannelPhase::UnfundedOutboundV2(chan) => {
1074810715
pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
1074910716
node_id: chan.context.get_counterparty_node_id(),
1075010717
msg: chan.get_open_channel_v2(self.chain_hash),
1075110718
});
1075210719
},
1075310720

10754-
ChannelPhase::UnfundedInboundV1(_) => {
10721+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1075510722
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1075610723
// they are not persisted and won't be recovered after a crash.
1075710724
// Therefore, they shouldn't exist at this point.
1075810725
debug_assert!(false);
1075910726
}
10760-
10761-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10762-
#[cfg(any(dual_funding, splicing))]
10763-
ChannelPhase::UnfundedInboundV2(channel) => {
10764-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10765-
// they are not persisted and won't be recovered after a crash.
10766-
// Therefore, they shouldn't exist at this point.
10767-
debug_assert!(false);
10768-
},
1076910727
}
1077010728
}
1077110729
}
@@ -10862,7 +10820,6 @@ where
1086210820
return;
1086310821
}
1086410822
},
10865-
#[cfg(any(dual_funding, splicing))]
1086610823
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1086710824
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1086810825
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10872,9 +10829,7 @@ where
1087210829
return;
1087310830
}
1087410831
},
10875-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10876-
#[cfg(any(dual_funding, splicing))]
10877-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10832+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1087810833
}
1087910834
}
1088010835

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)