Skip to content

Commit b5a1ffe

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 8aefaf7 commit b5a1ffe

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

@@ -7732,7 +7723,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77327723

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

@@ -8023,7 +8013,6 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80238013
// `ChannelMonitor`.
80248014
let mut channel = Channel {
80258015
context: self.context,
8026-
#[cfg(any(dual_funding, splicing))]
80278016
dual_funding_channel_context: None,
80288017
};
80298018
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8034,15 +8023,12 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80348023
}
80358024

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

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

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

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

93609344
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
93619345
},
9362-
#[cfg(any(dual_funding, splicing))]
93639346
dual_funding_channel_context: None,
93649347
})
93659348
}

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
927927
match phase {
928928
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
929929
ChannelPhase::UnfundedInboundV1(_) => false,
930-
#[cfg(any(dual_funding, splicing))]
931930
ChannelPhase::UnfundedOutboundV2(_) => true,
932-
#[cfg(any(dual_funding, splicing))]
933931
ChannelPhase::UnfundedInboundV2(_) => false,
934932
}
935933
)
@@ -2494,11 +2492,9 @@ macro_rules! convert_chan_phase_err {
24942492
ChannelPhase::UnfundedInboundV1(channel) => {
24952493
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
24962494
},
2497-
#[cfg(any(dual_funding, splicing))]
24982495
ChannelPhase::UnfundedOutboundV2(channel) => {
24992496
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25002497
},
2501-
#[cfg(any(dual_funding, splicing))]
25022498
ChannelPhase::UnfundedInboundV2(channel) => {
25032499
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
25042500
},
@@ -3370,13 +3366,7 @@ where
33703366
self.finish_close_channel(chan.context.force_shutdown(broadcast, closure_reason));
33713367
(self.get_channel_update_for_broadcast(&chan).ok(), chan.context.get_counterparty_node_id())
33723368
},
3373-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
3374-
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
3375-
// Unfunded channel has no update
3376-
(None, chan_phase.context().get_counterparty_node_id())
3377-
},
3378-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
3379-
#[cfg(any(dual_funding, splicing))]
3369+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
33803370
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
33813371
self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, closure_reason));
33823372
// Unfunded channel has no update
@@ -5719,12 +5709,10 @@ where
57195709
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
57205710
pending_msg_events, counterparty_node_id)
57215711
},
5722-
#[cfg(any(dual_funding, splicing))]
57235712
ChannelPhase::UnfundedInboundV2(chan) => {
57245713
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
57255714
pending_msg_events, counterparty_node_id)
57265715
},
5727-
#[cfg(any(dual_funding, splicing))]
57285716
ChannelPhase::UnfundedOutboundV2(chan) => {
57295717
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
57305718
pending_msg_events, counterparty_node_id)
@@ -6894,8 +6882,6 @@ where
68946882
num_unfunded_channels += 1;
68956883
}
68966884
},
6897-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
6898-
#[cfg(any(dual_funding, splicing))]
68996885
ChannelPhase::UnfundedInboundV2(chan) => {
69006886
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
69016887
// included in the unfunded count.
@@ -6904,16 +6890,10 @@ where
69046890
num_unfunded_channels += 1;
69056891
}
69066892
},
6907-
ChannelPhase::UnfundedOutboundV1(_) => {
6893+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
69086894
// Outbound channels don't contribute to the unfunded count in the DoS context.
69096895
continue;
69106896
},
6911-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
6912-
#[cfg(any(dual_funding, splicing))]
6913-
ChannelPhase::UnfundedOutboundV2(_) => {
6914-
// Outbound channels don't contribute to the unfunded count in the DoS context.
6915-
continue;
6916-
}
69176897
}
69186898
}
69196899
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -7329,21 +7309,14 @@ where
73297309
peer_state_lock, peer_state, per_peer_state, chan);
73307310
}
73317311
},
7332-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
7312+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
7313+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
73337314
let context = phase.context_mut();
73347315
let logger = WithChannelContext::from(&self.logger, context, None);
73357316
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
73367317
let mut chan = remove_channel_phase!(self, chan_phase_entry);
73377318
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
73387319
},
7339-
// TODO(dual_funding): Combine this match arm with above.
7340-
#[cfg(any(dual_funding, splicing))]
7341-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7342-
let context = phase.context_mut();
7343-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
7344-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
7345-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
7346-
},
73477320
}
73487321
} else {
73497322
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))
@@ -8219,7 +8192,7 @@ where
82198192
});
82208193
}
82218194
}
8222-
ChannelPhase::UnfundedInboundV1(_) => {},
8195+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {},
82238196
}
82248197
};
82258198

@@ -9383,9 +9356,7 @@ where
93839356
peer_state.channel_by_id.retain(|_, phase| {
93849357
match phase {
93859358
// Retain unfunded channels.
9386-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
9387-
// TODO(dual_funding): Combine this match arm with above.
9388-
#[cfg(any(dual_funding, splicing))]
9359+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
93899360
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
93909361
ChannelPhase::Funded(channel) => {
93919362
let res = f(channel);
@@ -9866,11 +9837,9 @@ where
98669837
ChannelPhase::UnfundedInboundV1(chan) => {
98679838
&mut chan.context
98689839
},
9869-
#[cfg(any(dual_funding, splicing))]
98709840
ChannelPhase::UnfundedOutboundV2(chan) => {
98719841
&mut chan.context
98729842
},
9873-
#[cfg(any(dual_funding, splicing))]
98749843
ChannelPhase::UnfundedInboundV2(chan) => {
98759844
&mut chan.context
98769845
},
@@ -10031,30 +10000,19 @@ where
1003110000
});
1003210001
}
1003310002

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

10043-
ChannelPhase::UnfundedInboundV1(_) => {
10010+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
1004410011
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
1004510012
// they are not persisted and won't be recovered after a crash.
1004610013
// Therefore, they shouldn't exist at this point.
1004710014
debug_assert!(false);
1004810015
}
10049-
10050-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
10051-
#[cfg(any(dual_funding, splicing))]
10052-
ChannelPhase::UnfundedInboundV2(channel) => {
10053-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10054-
// they are not persisted and won't be recovered after a crash.
10055-
// Therefore, they shouldn't exist at this point.
10056-
debug_assert!(false);
10057-
},
1005810016
}
1005910017
}
1006010018
}
@@ -10151,7 +10109,6 @@ where
1015110109
return;
1015210110
}
1015310111
},
10154-
#[cfg(any(dual_funding, splicing))]
1015510112
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1015610113
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1015710114
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10161,9 +10118,7 @@ where
1016110118
return;
1016210119
}
1016310120
},
10164-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10165-
#[cfg(any(dual_funding, splicing))]
10166-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10121+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1016710122
}
1016810123
}
1016910124

0 commit comments

Comments
 (0)