Skip to content

Commit 61d869f

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 960c570 commit 61d869f

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
@@ -5667,12 +5657,10 @@ where
56675657
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
56685658
pending_msg_events, counterparty_node_id)
56695659
},
5670-
#[cfg(any(dual_funding, splicing))]
56715660
ChannelPhase::UnfundedInboundV2(chan) => {
56725661
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
56735662
pending_msg_events, counterparty_node_id)
56745663
},
5675-
#[cfg(any(dual_funding, splicing))]
56765664
ChannelPhase::UnfundedOutboundV2(chan) => {
56775665
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
56785666
pending_msg_events, counterparty_node_id)
@@ -6842,8 +6830,6 @@ where
68426830
num_unfunded_channels += 1;
68436831
}
68446832
},
6845-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
6846-
#[cfg(any(dual_funding, splicing))]
68476833
ChannelPhase::UnfundedInboundV2(chan) => {
68486834
// Only inbound V2 channels that are not 0conf and that we do not contribute to will be
68496835
// included in the unfunded count.
@@ -6852,16 +6838,10 @@ where
68526838
num_unfunded_channels += 1;
68536839
}
68546840
},
6855-
ChannelPhase::UnfundedOutboundV1(_) => {
6841+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedOutboundV2(_) => {
68566842
// Outbound channels don't contribute to the unfunded count in the DoS context.
68576843
continue;
68586844
},
6859-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
6860-
#[cfg(any(dual_funding, splicing))]
6861-
ChannelPhase::UnfundedOutboundV2(_) => {
6862-
// Outbound channels don't contribute to the unfunded count in the DoS context.
6863-
continue;
6864-
}
68656845
}
68666846
}
68676847
num_unfunded_channels + peer.inbound_channel_request_by_id.len()
@@ -7277,21 +7257,14 @@ where
72777257
peer_state_lock, peer_state, per_peer_state, chan);
72787258
}
72797259
},
7280-
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
7260+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) |
7261+
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
72817262
let context = phase.context_mut();
72827263
let logger = WithChannelContext::from(&self.logger, context, None);
72837264
log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
72847265
let mut chan = remove_channel_phase!(self, chan_phase_entry);
72857266
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
72867267
},
7287-
// TODO(dual_funding): Combine this match arm with above.
7288-
#[cfg(any(dual_funding, splicing))]
7289-
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7290-
let context = phase.context_mut();
7291-
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
7292-
let mut chan = remove_channel_phase!(self, chan_phase_entry);
7293-
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
7294-
},
72957268
}
72967269
} else {
72977270
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))
@@ -8167,7 +8140,7 @@ where
81678140
});
81688141
}
81698142
}
8170-
ChannelPhase::UnfundedInboundV1(_) => {},
8143+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {},
81718144
}
81728145
};
81738146

@@ -9331,9 +9304,7 @@ where
93319304
peer_state.channel_by_id.retain(|_, phase| {
93329305
match phase {
93339306
// Retain unfunded channels.
9334-
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
9335-
// TODO(dual_funding): Combine this match arm with above.
9336-
#[cfg(any(dual_funding, splicing))]
9307+
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) |
93379308
ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
93389309
ChannelPhase::Funded(channel) => {
93399310
let res = f(channel);
@@ -9814,11 +9785,9 @@ where
98149785
ChannelPhase::UnfundedInboundV1(chan) => {
98159786
&mut chan.context
98169787
},
9817-
#[cfg(any(dual_funding, splicing))]
98189788
ChannelPhase::UnfundedOutboundV2(chan) => {
98199789
&mut chan.context
98209790
},
9821-
#[cfg(any(dual_funding, splicing))]
98229791
ChannelPhase::UnfundedInboundV2(chan) => {
98239792
&mut chan.context
98249793
},
@@ -9979,30 +9948,19 @@ where
99799948
});
99809949
}
99819950

9982-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
9983-
#[cfg(any(dual_funding, splicing))]
99849951
ChannelPhase::UnfundedOutboundV2(chan) => {
99859952
pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
99869953
node_id: chan.context.get_counterparty_node_id(),
99879954
msg: chan.get_open_channel_v2(self.chain_hash),
99889955
});
99899956
},
99909957

9991-
ChannelPhase::UnfundedInboundV1(_) => {
9958+
ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) => {
99929959
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
99939960
// they are not persisted and won't be recovered after a crash.
99949961
// Therefore, they shouldn't exist at this point.
99959962
debug_assert!(false);
99969963
}
9997-
9998-
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
9999-
#[cfg(any(dual_funding, splicing))]
10000-
ChannelPhase::UnfundedInboundV2(channel) => {
10001-
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
10002-
// they are not persisted and won't be recovered after a crash.
10003-
// Therefore, they shouldn't exist at this point.
10004-
debug_assert!(false);
10005-
},
100069964
}
100079965
}
100089966
}
@@ -10099,7 +10057,6 @@ where
1009910057
return;
1010010058
}
1010110059
},
10102-
#[cfg(any(dual_funding, splicing))]
1010310060
Some(ChannelPhase::UnfundedOutboundV2(ref mut chan)) => {
1010410061
if let Ok(msg) = chan.maybe_handle_error_without_close(self.chain_hash, &self.fee_estimator) {
1010510062
peer_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannelV2 {
@@ -10109,9 +10066,7 @@ where
1010910066
return;
1011010067
}
1011110068
},
10112-
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::Funded(_)) => (),
10113-
#[cfg(any(dual_funding, splicing))]
10114-
Some(ChannelPhase::UnfundedInboundV2(_)) => (),
10069+
None | Some(ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::Funded(_)) => (),
1011510070
}
1011610071
}
1011710072

0 commit comments

Comments
 (0)