Skip to content

Commit a7b1b64

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 cfd7f18 commit a7b1b64

File tree

2 files changed

+8
-70
lines changed

2 files changed

+8
-70
lines changed

lightning/src/ln/channel.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,7 @@ impl_writeable_tlv_based!(PendingChannelMonitorUpdate, {
10831083
pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
10841084
UnfundedOutboundV1(OutboundV1Channel<SP>),
10851085
UnfundedInboundV1(InboundV1Channel<SP>),
1086-
#[cfg(any(dual_funding, splicing))]
10871086
UnfundedOutboundV2(OutboundV2Channel<SP>),
1088-
#[cfg(any(dual_funding, splicing))]
10891087
UnfundedInboundV2(InboundV2Channel<SP>),
10901088
Funded(Channel<SP>),
10911089
}
@@ -1099,9 +1097,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
10991097
ChannelPhase::Funded(chan) => &chan.context,
11001098
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
11011099
ChannelPhase::UnfundedInboundV1(chan) => &chan.context,
1102-
#[cfg(any(dual_funding, splicing))]
11031100
ChannelPhase::UnfundedOutboundV2(chan) => &chan.context,
1104-
#[cfg(any(dual_funding, splicing))]
11051101
ChannelPhase::UnfundedInboundV2(chan) => &chan.context,
11061102
}
11071103
}
@@ -1111,9 +1107,7 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11111107
ChannelPhase::Funded(ref mut chan) => &mut chan.context,
11121108
ChannelPhase::UnfundedOutboundV1(ref mut chan) => &mut chan.context,
11131109
ChannelPhase::UnfundedInboundV1(ref mut chan) => &mut chan.context,
1114-
#[cfg(any(dual_funding, splicing))]
11151110
ChannelPhase::UnfundedOutboundV2(ref mut chan) => &mut chan.context,
1116-
#[cfg(any(dual_funding, splicing))]
11171111
ChannelPhase::UnfundedInboundV2(ref mut chan) => &mut chan.context,
11181112
}
11191113
}
@@ -3580,7 +3574,6 @@ pub(crate) fn get_legacy_default_holder_selected_channel_reserve_satoshis(channe
35803574
///
35813575
/// This is used both for outbound and inbound channels and has lower bound
35823576
/// of `dust_limit_satoshis`.
3583-
#[cfg(any(dual_funding, splicing))]
35843577
fn get_v2_channel_reserve_satoshis(channel_value_satoshis: u64, dust_limit_satoshis: u64) -> u64 {
35853578
// Fixed at 1% of channel value by spec.
35863579
let (q, _) = channel_value_satoshis.overflowing_div(100);
@@ -3614,7 +3607,6 @@ pub(crate) fn per_outbound_htlc_counterparty_commit_tx_fee_msat(feerate_per_kw:
36143607
}
36153608

36163609
/// Context for dual-funded channels.
3617-
#[cfg(any(dual_funding, splicing))]
36183610
pub(super) struct DualFundingChannelContext {
36193611
/// The amount in satoshis we will be contributing to the channel.
36203612
pub our_funding_satoshis: u64,
@@ -3631,7 +3623,6 @@ pub(super) struct DualFundingChannelContext {
36313623
// Counterparty designates channel data owned by the another channel participant entity.
36323624
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
36333625
pub context: ChannelContext<SP>,
3634-
#[cfg(any(dual_funding, splicing))]
36353626
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
36363627
}
36373628

@@ -7733,7 +7724,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77337724

77347725
let mut channel = Channel {
77357726
context: self.context,
7736-
#[cfg(any(dual_funding, splicing))]
77377727
dual_funding_channel_context: None,
77387728
};
77397729

@@ -8024,7 +8014,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80248014
// `ChannelMonitor`.
80258015
let mut channel = Channel {
80268016
context: self.context,
8027-
#[cfg(any(dual_funding, splicing))]
80288017
dual_funding_channel_context: None,
80298018
};
80308019
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8035,15 +8024,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80358024
}
80368025

80378026
// A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8038-
#[cfg(any(dual_funding, splicing))]
80398027
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
80408028
pub context: ChannelContext<SP>,
80418029
pub unfunded_context: UnfundedChannelContext,
8042-
#[cfg(any(dual_funding, splicing))]
80438030
pub dual_funding_context: DualFundingChannelContext,
80448031
}
80458032

8046-
#[cfg(any(dual_funding, splicing))]
80478033
impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
80488034
pub fn new<ES: Deref, F: Deref>(
80498035
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
@@ -8159,14 +8145,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
81598145
}
81608146

81618147
// A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8162-
#[cfg(any(dual_funding, splicing))]
81638148
pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
81648149
pub context: ChannelContext<SP>,
81658150
pub unfunded_context: UnfundedChannelContext,
81668151
pub dual_funding_context: DualFundingChannelContext,
81678152
}
81688153

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

93619345
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
93629346
},
9363-
#[cfg(any(dual_funding, splicing))]
93649347
dual_funding_channel_context: None,
93659348
})
93669349
}

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
928928
match phase {
929929
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
930930
ChannelPhase::UnfundedInboundV1(_) => false,
931-
#[cfg(any(dual_funding, splicing))]
932931
ChannelPhase::UnfundedOutboundV2(_) => true,
933-
#[cfg(any(dual_funding, splicing))]
934932
ChannelPhase::UnfundedInboundV2(_) => false,
935933
}
936934
)
@@ -2495,11 +2493,9 @@ macro_rules! convert_chan_phase_err {
24952493
ChannelPhase::UnfundedInboundV1(channel) => {
24962494
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
24972495
},
2498-
#[cfg(any(dual_funding, splicing))]
24992496
ChannelPhase::UnfundedOutboundV2(channel) => {
25002497
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25012498
},
2502-
#[cfg(any(dual_funding, splicing))]
25032499
ChannelPhase::UnfundedInboundV2(channel) => {
25042500
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25052501
},
@@ -3371,13 +3367,7 @@ where
33713367
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
33723368
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
33733369
},
3374-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
3375-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
3376-
// Unfunded channel has no update
3377-
(None, chan_phase.context().get_counterparty_node_id())
3378-
},
3379-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
3380-
#[cfg(any(dual_funding, splicing))]
3370+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
33813371
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
33823372
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
33833373
// Unfunded channel has no update
@@ -5721,12 +5711,10 @@ where
57215711
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
57225712
pending_msg_events, counterparty_node_id)
57235713
},
5724-
#[cfg(any(dual_funding, splicing))]
57255714
ChannelPhase::UnfundedInboundV2(chan) => {
57265715
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
57275716
pending_msg_events, counterparty_node_id)
57285717
},
5729-
#[cfg(any(dual_funding, splicing))]
57305718
ChannelPhase::UnfundedOutboundV2(chan) => {
57315719
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
57325720
pending_msg_events, counterparty_node_id)
@@ -6896,8 +6884,6 @@ where
68966884
num_unfunded_channels += 1;
68976885
}
68986886
},
6899-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
6900-
#[cfg(any(dual_funding, splicing))]
69016887
ChannelPhase::UnfundedInboundV2(chan) => {
69026888
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
69036889
// included in the unfunded count.
@@ -6906,16 +6892,10 @@ where
69066892
num_unfunded_channels += 1;
69076893
}
69086894
},
6909-
ChannelPhase::UnfundedOutboundV1(_) => {
6895+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
69106896
// Outbound channels don't contribute to the unfunded count in the DoS context.
69116897
continue;
69126898
},
6913-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
6914-
#[cfg(any(dual_funding, splicing))]
6915-
ChannelPhase::UnfundedOutboundV2(_) => {
6916-
// Outbound channels don't contribute to the unfunded count in the DoS context.
6917-
continue;
6918-
}
69196899
}
69206900
}
69216901
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -7331,21 +7311,14 @@ where
73317311
peer_state_lock, peer_state, per_peer_state, chan);
73327312
}
73337313
},
7334-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
7314+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
7315+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
73357316
let context = phase.context_mut();
73367317
let logger = WithChannelContext::from(&self.logger, context, None);
73377318
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
73387319
let mut chan = remove_channel_phase!(self, chan_phase_entry);
73397320
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
73407321
},
7341-
// TODO(dual_funding): Combine this match arm with above.
7342-
#[cfg(any(dual_funding, splicing))]
7343-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7344-
let context = phase.context_mut();
7345-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
7346-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
7347-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
7348-
},
73497322
}
73507323
} else {
73517324
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))
@@ -8221,7 +8194,7 @@ where
82218194
});
82228195
}
82238196
}
8224-
ChannelPhase::UnfundedInboundV1(_) => {},
8197+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {},
82258198
}
82268199
};
82278200

@@ -9385,9 +9358,7 @@ where
93859358
peer_state.channel_by_id.retain(|_, phase| {
93869359
match phase {
93879360
// Retain unfunded channels.
9388-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
9389-
// TODO(dual_funding): Combine this match arm with above.
9390-
#[cfg(any(dual_funding, splicing))]
9361+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
93919362
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
93929363
ChannelPhase::Funded(channel) => {
93939364
let res = f(channel);
@@ -9868,11 +9839,9 @@ where
98689839
ChannelPhase::UnfundedInboundV1(chan) => {
98699840
&mut chan.context
98709841
},
9871-
#[cfg(any(dual_funding, splicing))]
98729842
ChannelPhase::UnfundedOutboundV2(chan) => {
98739843
&mut chan.context
98749844
},
9875-
#[cfg(any(dual_funding, splicing))]
98769845
ChannelPhase::UnfundedInboundV2(chan) => {
98779846
&mut chan.context
98789847
},
@@ -10033,30 +10002,19 @@ where
1003310002
});
1003410003
}
1003510004

10036-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10037-
#[cfg(any(dual_funding, splicing))]
1003810005
ChannelPhase::UnfundedOutboundV2(chan) => {
1003910006
pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
1004010007
node_id: chan.context.get_counterparty_node_id(),
1004110008
msg: chan.get_open_channel_v2(self.chain_hash),
1004210009
});
1004310010
},
1004410011

10045-
ChannelPhase::UnfundedInboundV1(_) => {
10012+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1004610013
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1004710014
// they are not persisted and won't be recovered after a crash.
1004810015
// Therefore, they shouldn't exist at this point.
1004910016
debug_assert!(false);
1005010017
}
10051-
10052-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10053-
#[cfg(any(dual_funding, splicing))]
10054-
ChannelPhase::UnfundedInboundV2(channel) => {
10055-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10056-
// they are not persisted and won't be recovered after a crash.
10057-
// Therefore, they shouldn't exist at this point.
10058-
debug_assert!(false);
10059-
},
1006010018
}
1006110019
}
1006210020
}
@@ -10153,7 +10111,6 @@ where
1015310111
return;
1015410112
}
1015510113
},
10156-
#[cfg(any(dual_funding, splicing))]
1015710114
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1015810115
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1015910116
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10163,9 +10120,7 @@ where
1016310120
return;
1016410121
}
1016510122
},
10166-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10167-
#[cfg(any(dual_funding, splicing))]
10168-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10123+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1016910124
}
1017010125
}
1017110126

0 commit comments

Comments
 (0)