Skip to content

Commit 15d41a2

Browse files
committed
Remove superfluous channel-value-goes-below-0 checks
1 parent 84f659e commit 15d41a2

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4617,6 +4617,7 @@ pub(super) fn calculate_our_funding_satoshis(
46174617
/// the fees of the inputs, fees of the inputs weight, and for the initiator,
46184618
/// the fees of the common fields as well as the output and extra input weights.
46194619
/// Returns estimated (partial) fees as additional information
4620+
#[cfg(splicing)]
46204621
pub(super) fn check_v2_funding_inputs_sufficient(
46214622
contribution_amount: i64, funding_inputs: &[(TxIn, Transaction, Weight)], is_initiator: bool,
46224623
extra_common_input_weight: Option<Weight>, funding_feerate_sat_per_1000_weight: u32,
@@ -8289,13 +8290,6 @@ impl<SP: Deref> FundedChannel<SP> where
82898290
// TODO(splicing): check for quiescence
82908291

82918292
let pre_channel_value = self.context.get_value_satoshis();
8292-
// Sanity check: capacity cannot decrease below 0
8293-
if (pre_channel_value as i64).saturating_add(our_funding_contribution_satoshis) < 0 {
8294-
return Err(ChannelError::Warn(format!(
8295-
"Post-splicing channel value cannot be negative. It was {} + {}",
8296-
pre_channel_value, our_funding_contribution_satoshis
8297-
)));
8298-
}
82998293

83008294
if our_funding_contribution_satoshis < 0 {
83018295
return Err(ChannelError::Warn(format!(
@@ -8304,6 +8298,9 @@ impl<SP: Deref> FundedChannel<SP> where
83048298
)));
83058299
}
83068300

8301+
// TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
8302+
// (or below channel reserve)
8303+
83078304
// Note: post-splice channel value is not yet known at this point, counterparty contribution is not known
83088305
// (Cannot test for miminum required post-splice channel value)
83098306

@@ -8347,16 +8344,6 @@ impl<SP: Deref> FundedChannel<SP> where
83478344
}
83488345

83498346
let pre_channel_value = self.context.get_value_satoshis();
8350-
// Sanity check: capacity cannot decrease below 0
8351-
if (pre_channel_value as i64)
8352-
.saturating_add(their_funding_contribution_satoshis)
8353-
.saturating_add(our_funding_contribution_satoshis) < 0
8354-
{
8355-
return Err(ChannelError::Warn(format!(
8356-
"Post-splicing channel value cannot be negative. It was {} + {} + {}",
8357-
pre_channel_value, their_funding_contribution_satoshis, our_funding_contribution_satoshis,
8358-
)));
8359-
}
83608347

83618348
if their_funding_contribution_satoshis.saturating_add(our_funding_contribution_satoshis) < 0 {
83628349
return Err(ChannelError::Warn(format!(
@@ -8365,8 +8352,11 @@ impl<SP: Deref> FundedChannel<SP> where
83658352
)));
83668353
}
83678354

8355+
// TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
8356+
// similarly to the check in `splice_channel`.
8357+
83688358
// Note on channel reserve requirement pre-check: as the splice acceptor does not contribute,
8369-
// it can go below reserve, therefore no pre-check is done here.
8359+
// it can't go below reserve, therefore no pre-check is done here.
83708360
// TODO(splicing): Once splice acceptor can contribute, add reserve pre-check, similar to the one in `splice_ack`.
83718361

83728362
// TODO(splicing): Store msg.funding_pubkey

0 commit comments

Comments
 (0)