Skip to content

Commit 15f1c21

Browse files
committed
f - Always pass FundingScope
1 parent 04abb58 commit 15f1c21

File tree

1 file changed

+10
-40
lines changed

1 file changed

+10
-40
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,17 +3868,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38683868
}
38693869

38703870
let htlc_above_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000, HTLCInitiator::LocalOffered);
3871-
let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(
3872-
#[cfg(any(test, fuzzing))]
3873-
&funding,
3874-
htlc_above_dust, Some(()),
3875-
);
3871+
let mut max_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_above_dust, Some(()));
38763872
let htlc_dust = HTLCCandidate::new(real_dust_limit_timeout_sat * 1000 - 1, HTLCInitiator::LocalOffered);
3877-
let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(
3878-
#[cfg(any(test, fuzzing))]
3879-
&funding,
3880-
htlc_dust, Some(()),
3881-
);
3873+
let mut min_reserved_commit_tx_fee_msat = context.next_local_commit_tx_fee_msat(&funding, htlc_dust, Some(()));
38823874
if !context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
38833875
max_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
38843876
min_reserved_commit_tx_fee_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
@@ -3907,11 +3899,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
39073899
}
39083900

39093901
let htlc_above_dust = HTLCCandidate::new(real_dust_limit_success_sat * 1000, HTLCInitiator::LocalOffered);
3910-
let max_reserved_commit_tx_fee_msat = context.next_remote_commit_tx_fee_msat(
3911-
#[cfg(any(test, fuzzing))]
3912-
&funding,
3913-
Some(htlc_above_dust), None,
3914-
);
3902+
let max_reserved_commit_tx_fee_msat = context.next_remote_commit_tx_fee_msat(&funding, Some(htlc_above_dust), None);
39153903

39163904
let holder_selected_chan_reserve_msat = funding.holder_selected_channel_reserve_satoshis * 1000;
39173905
let remote_balance_msat = (funding.channel_value_satoshis * 1000 - funding.value_to_self_msat)
@@ -4009,10 +3997,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
40093997
///
40103998
/// Dust HTLCs are excluded.
40113999
fn next_local_commit_tx_fee_msat(
4012-
&self,
4013-
#[cfg(any(test, fuzzing))]
4014-
funding: &FundingScope,
4015-
htlc: HTLCCandidate, fee_spike_buffer_htlc: Option<()>,
4000+
&self, _funding: &FundingScope, htlc: HTLCCandidate, fee_spike_buffer_htlc: Option<()>,
40164001
) -> u64 {
40174002
let context = &self;
40184003
assert!(context.is_outbound());
@@ -4102,7 +4087,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
41024087
},
41034088
feerate: context.feerate_per_kw,
41044089
};
4105-
*funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
4090+
*_funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
41064091
}
41074092
res
41084093
}
@@ -4118,10 +4103,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
41184103
///
41194104
/// Dust HTLCs are excluded.
41204105
fn next_remote_commit_tx_fee_msat(
4121-
&self,
4122-
#[cfg(any(test, fuzzing))]
4123-
funding: &FundingScope,
4124-
htlc: Option<HTLCCandidate>, fee_spike_buffer_htlc: Option<()>,
4106+
&self, _funding: &FundingScope, htlc: Option<HTLCCandidate>, fee_spike_buffer_htlc: Option<()>,
41254107
) -> u64 {
41264108
debug_assert!(htlc.is_some() || fee_spike_buffer_htlc.is_some(), "At least one of the options must be set");
41274109

@@ -4201,7 +4183,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
42014183
},
42024184
feerate: context.feerate_per_kw,
42034185
};
4204-
*funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
4186+
*_funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
42054187
}
42064188
res
42074189
}
@@ -5221,11 +5203,7 @@ impl<SP: Deref> FundedChannel<SP> where
52215203
{
52225204
let remote_commit_tx_fee_msat = if self.context.is_outbound() { 0 } else {
52235205
let htlc_candidate = HTLCCandidate::new(msg.amount_msat, HTLCInitiator::RemoteOffered);
5224-
self.context.next_remote_commit_tx_fee_msat(
5225-
#[cfg(any(test, fuzzing))]
5226-
&self.funding,
5227-
Some(htlc_candidate), None, // Don't include the extra fee spike buffer HTLC in calculations
5228-
)
5206+
self.context.next_remote_commit_tx_fee_msat(&self.funding, Some(htlc_candidate), None) // Don't include the extra fee spike buffer HTLC in calculations
52295207
};
52305208
let anchor_outputs_value_msat = if !self.context.is_outbound() && self.context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
52315209
ANCHOR_OUTPUT_VALUE_SATOSHI * 2 * 1000
@@ -5248,11 +5226,7 @@ impl<SP: Deref> FundedChannel<SP> where
52485226
if self.context.is_outbound() {
52495227
// Check that they won't violate our local required channel reserve by adding this HTLC.
52505228
let htlc_candidate = HTLCCandidate::new(msg.amount_msat, HTLCInitiator::RemoteOffered);
5251-
let local_commit_tx_fee_msat = self.context.next_local_commit_tx_fee_msat(
5252-
#[cfg(any(test, fuzzing))]
5253-
&self.funding,
5254-
htlc_candidate, None,
5255-
);
5229+
let local_commit_tx_fee_msat = self.context.next_local_commit_tx_fee_msat(&self.funding, htlc_candidate, None);
52565230
if self.funding.value_to_self_msat < self.funding.counterparty_selected_channel_reserve_satoshis.unwrap() * 1000 + local_commit_tx_fee_msat + anchor_outputs_value_msat {
52575231
return Err(ChannelError::close("Cannot accept HTLC that would put our balance under counterparty-announced channel reserve value".to_owned()));
52585232
}
@@ -7441,11 +7415,7 @@ impl<SP: Deref> FundedChannel<SP> where
74417415
//
74427416
// A `None` `HTLCCandidate` is used as in this case because we're already accounting for
74437417
// the incoming HTLC as it has been fully committed by both sides.
7444-
let mut remote_fee_cost_incl_stuck_buffer_msat = self.context.next_remote_commit_tx_fee_msat(
7445-
#[cfg(any(test, fuzzing))]
7446-
&self.funding,
7447-
None, Some(()),
7448-
);
7418+
let mut remote_fee_cost_incl_stuck_buffer_msat = self.context.next_remote_commit_tx_fee_msat(&self.funding, None, Some(()));
74497419
if !self.context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
74507420
remote_fee_cost_incl_stuck_buffer_msat *= FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
74517421
}

0 commit comments

Comments
 (0)