Skip to content

Commit f908780

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 a3129ee commit f908780

File tree

5 files changed

+9
-74
lines changed

5 files changed

+9
-74
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ check-cfg = [
6060
"cfg(taproot)",
6161
"cfg(async_signing)",
6262
"cfg(require_route_graph_test)",
63-
"cfg(dual_funding)",
6463
"cfg(splicing)",
6564
"cfg(async_payments)",
6665
]

ci/ci-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
176176
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
177177
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
178178
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
179-
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
180-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
181179
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
182180
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
183181
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
@@ -1085,9 +1085,7 @@ impl_writeable_tlv_based!(PendingChannelMonitorUpdate, {
10851085
pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
10861086
UnfundedOutboundV1(OutboundV1Channel<SP>),
10871087
UnfundedInboundV1(InboundV1Channel<SP>),
1088-
#[cfg(any(dual_funding, splicing))]
10891088
UnfundedOutboundV2(OutboundV2Channel<SP>),
1090-
#[cfg(any(dual_funding, splicing))]
10911089
UnfundedInboundV2(InboundV2Channel<SP>),
10921090
Funded(Channel<SP>),
10931091
}
@@ -1101,9 +1099,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11011099
ChannelPhase::Funded(chan) => &chan.context,
11021100
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
11031101
ChannelPhase::UnfundedInboundV1(chan) => &chan.context,
1104-
#[cfg(any(dual_funding, splicing))]
11051102
ChannelPhase::UnfundedOutboundV2(chan) => &chan.context,
1106-
#[cfg(any(dual_funding, splicing))]
11071103
ChannelPhase::UnfundedInboundV2(chan) => &chan.context,
11081104
}
11091105
}
@@ -1113,9 +1109,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11131109
ChannelPhase::Funded(ref mut chan) => &mut chan.context,
11141110
ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context,
11151111
ChannelPhase::UnfundedInboundV1(ref mut chan) => &mut chan.context,
1116-
#[cfg(any(dual_funding, splicing))]
11171112
ChannelPhase::UnfundedOutboundV2(ref mut chan) => &mut chan.context,
1118-
#[cfg(any(dual_funding, splicing))]
11191113
ChannelPhase::UnfundedInboundV2(ref mut chan) => &mut chan.context,
11201114
}
11211115
}
@@ -3592,7 +3586,6 @@ pub(crate) fn get_legacy_default_holder_selected_channel_reserve_satoshis(channe
35923586
///
35933587
/// This is used both for outbound and inbound channels and has lower bound
35943588
/// of `dust_limit_satoshis`.
3595-
#[cfg(any(dual_funding, splicing))]
35963589
fn get_v2_channel_reserve_satoshis(channel_value_satoshis: u64, dust_limit_satoshis: u64) -> u64 {
35973590
// Fixed at 1% of channel value by spec.
35983591
let (q, _) = channel_value_satoshis.overflowing_div(100);
@@ -3626,7 +3619,6 @@ pub(crate) fn per_outbound_htlc_counterparty_commit_tx_fee_msat(feerate_per_kw:
36263619
}
36273620

36283621
/// Context for dual-funded channels.
3629-
#[cfg(any(dual_funding, splicing))]
36303622
pub(super) struct DualFundingChannelContext {
36313623
/// The amount in satoshis we will be contributing to the channel.
36323624
pub our_funding_satoshis: u64,
@@ -3643,7 +3635,6 @@ pub(super) struct DualFundingChannelContext {
36433635
// Counterparty designates channel data owned by the another channel participant entity.
36443636
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
36453637
pub context: ChannelContext<SP>,
3646-
#[cfg(any(dual_funding, splicing))]
36473638
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
36483639
}
36493640

@@ -7783,7 +7774,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77837774

77847775
let mut channel = Channel {
77857776
context: self.context,
7786-
#[cfg(any(dual_funding, splicing))]
77877777
dual_funding_channel_context: None,
77887778
};
77897779

@@ -8074,7 +8064,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80748064
// `ChannelMonitor`.
80758065
let mut channel = Channel {
80768066
context: self.context,
8077-
#[cfg(any(dual_funding, splicing))]
80788067
dual_funding_channel_context: None,
80798068
};
80808069
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8085,15 +8074,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80858074
}
80868075

80878076
// A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8088-
#[cfg(any(dual_funding, splicing))]
80898077
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
80908078
pub context: ChannelContext<SP>,
80918079
pub unfunded_context: UnfundedChannelContext,
8092-
#[cfg(any(dual_funding, splicing))]
80938080
pub dual_funding_context: DualFundingChannelContext,
80948081
}
80958082

8096-
#[cfg(any(dual_funding, splicing))]
80978083
impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
80988084
pub fn new<ES: Deref, F: Deref>(
80998085
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
@@ -8209,14 +8195,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
82098195
}
82108196

82118197
// A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8212-
#[cfg(any(dual_funding, splicing))]
82138198
pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
82148199
pub context: ChannelContext<SP>,
82158200
pub unfunded_context: UnfundedChannelContext,
82168201
pub dual_funding_context: DualFundingChannelContext,
82178202
}
82188203

8219-
#[cfg(any(dual_funding, splicing))]
82208204
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
82218205
/// Creates a new dual-funded channel from a remote side's request for one.
82228206
/// Assumes chain_hash has already been checked and corresponds with what we expect!
@@ -9411,7 +9395,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
94119395

94129396
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
94139397
},
9414-
#[cfg(any(dual_funding, splicing))]
94159398
dual_funding_channel_context: None,
94169399
})
94179400
}

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
10121012
match phase {
10131013
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
10141014
ChannelPhase::UnfundedInboundV1(_) => false,
1015-
#[cfg(any(dual_funding, splicing))]
10161015
ChannelPhase::UnfundedOutboundV2(_) => true,
1017-
#[cfg(any(dual_funding, splicing))]
10181016
ChannelPhase::UnfundedInboundV2(_) => false,
10191017
}
10201018
)
@@ -2579,11 +2577,9 @@ macro_rules! convert_chan_phase_err {
25792577
ChannelPhase::UnfundedInboundV1(channel) => {
25802578
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25812579
},
2582-
#[cfg(any(dual_funding, splicing))]
25832580
ChannelPhase::UnfundedOutboundV2(channel) => {
25842581
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25852582
},
2586-
#[cfg(any(dual_funding, splicing))]
25872583
ChannelPhase::UnfundedInboundV2(channel) => {
25882584
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25892585
},
@@ -3455,13 +3451,7 @@ where
34553451
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
34563452
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
34573453
},
3458-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
3459-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
3460-
// Unfunded channel has no update
3461-
(None, chan_phase.context().get_counterparty_node_id())
3462-
},
3463-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
3464-
#[cfg(any(dual_funding, splicing))]
3454+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
34653455
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
34663456
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
34673457
// Unfunded channel has no update
@@ -5816,12 +5806,10 @@ where
58165806
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
58175807
pending_msg_events, counterparty_node_id)
58185808
},
5819-
#[cfg(any(dual_funding, splicing))]
58205809
ChannelPhase::UnfundedInboundV2(chan) => {
58215810
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
58225811
pending_msg_events, counterparty_node_id)
58235812
},
5824-
#[cfg(any(dual_funding, splicing))]
58255813
ChannelPhase::UnfundedOutboundV2(chan) => {
58265814
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
58275815
pending_msg_events, counterparty_node_id)
@@ -7119,8 +7107,6 @@ where
71197107
num_unfunded_channels += 1;
71207108
}
71217109
},
7122-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7123-
#[cfg(any(dual_funding, splicing))]
71247110
ChannelPhase::UnfundedInboundV2(chan) => {
71257111
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
71267112
// included in the unfunded count.
@@ -7129,16 +7115,10 @@ where
71297115
num_unfunded_channels += 1;
71307116
}
71317117
},
7132-
ChannelPhase::UnfundedOutboundV1(_) => {
7118+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
71337119
// Outbound channels don't contribute to the unfunded count in the DoS context.
71347120
continue;
71357121
},
7136-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
7137-
#[cfg(any(dual_funding, splicing))]
7138-
ChannelPhase::UnfundedOutboundV2(_) => {
7139-
// Outbound channels don't contribute to the unfunded count in the DoS context.
7140-
continue;
7141-
}
71427122
}
71437123
}
71447124
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -7554,21 +7534,14 @@ where
75547534
peer_state_lock, peer_state, per_peer_state, chan);
75557535
}
75567536
},
7557-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
7537+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
7538+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
75587539
let context = phase.context_mut();
75597540
let logger = WithChannelContext::from(&self.logger, context, None);
75607541
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
75617542
let mut chan = remove_channel_phase!(self, chan_phase_entry);
75627543
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
75637544
},
7564-
// TODO(dual_funding): Combine this match arm with above.
7565-
#[cfg(any(dual_funding, splicing))]
7566-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7567-
let context = phase.context_mut();
7568-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
7569-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
7570-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
7571-
},
75727545
}
75737546
} else {
75747547
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))
@@ -8466,7 +8439,7 @@ where
84668439
});
84678440
}
84688441
}
8469-
ChannelPhase::UnfundedInboundV1(_) => {},
8442+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {},
84708443
}
84718444
};
84728445

@@ -9633,9 +9606,7 @@ where
96339606
peer_state.channel_by_id.retain(|_, phase| {
96349607
match phase {
96359608
// Retain unfunded channels.
9636-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
9637-
// TODO(dual_funding): Combine this match arm with above.
9638-
#[cfg(any(dual_funding, splicing))]
9609+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
96399610
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
96409611
ChannelPhase::Funded(channel) => {
96419612
let res = f(channel);
@@ -10117,11 +10088,9 @@ where
1011710088
ChannelPhase::UnfundedInboundV1(chan) => {
1011810089
&mut chan.context
1011910090
},
10120-
#[cfg(any(dual_funding, splicing))]
1012110091
ChannelPhase::UnfundedOutboundV2(chan) => {
1012210092
&mut chan.context
1012310093
},
10124-
#[cfg(any(dual_funding, splicing))]
1012510094
ChannelPhase::UnfundedInboundV2(chan) => {
1012610095
&mut chan.context
1012710096
},
@@ -10282,30 +10251,19 @@ where
1028210251
});
1028310252
}
1028410253

10285-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10286-
#[cfg(any(dual_funding, splicing))]
1028710254
ChannelPhase::UnfundedOutboundV2(chan) => {
1028810255
pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
1028910256
node_id: chan.context.get_counterparty_node_id(),
1029010257
msg: chan.get_open_channel_v2(self.chain_hash),
1029110258
});
1029210259
},
1029310260

10294-
ChannelPhase::UnfundedInboundV1(_) => {
10261+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1029510262
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1029610263
// they are not persisted and won't be recovered after a crash.
1029710264
// Therefore, they shouldn't exist at this point.
1029810265
debug_assert!(false);
1029910266
}
10300-
10301-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10302-
#[cfg(any(dual_funding, splicing))]
10303-
ChannelPhase::UnfundedInboundV2(channel) => {
10304-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10305-
// they are not persisted and won't be recovered after a crash.
10306-
// Therefore, they shouldn't exist at this point.
10307-
debug_assert!(false);
10308-
},
1030910267
}
1031010268
}
1031110269
}
@@ -10402,7 +10360,6 @@ where
1040210360
return;
1040310361
}
1040410362
},
10405-
#[cfg(any(dual_funding, splicing))]
1040610363
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1040710364
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1040810365
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10412,9 +10369,7 @@ where
1041210369
return;
1041310370
}
1041410371
},
10415-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10416-
#[cfg(any(dual_funding, splicing))]
10417-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10372+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1041810373
}
1041910374
}
1042010375

lightning/src/ln/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mod async_signer_tests;
8585
#[cfg(test)]
8686
#[allow(unused_mut)]
8787
mod offers_tests;
88-
#[allow(dead_code)] // TODO(dual_funding): Exchange for dual_funding cfg
88+
#[allow(dead_code)] // TODO(splicing): Exchange for splicing cfg
8989
pub(crate) mod interactivetxs;
9090

9191
pub use self::peer_channel_encryptor::LN_MAX_MSG_LEN;

0 commit comments

Comments
 (0)