@@ -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)]
46204621pub(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,
@@ -8288,22 +8289,16 @@ impl<SP: Deref> FundedChannel<SP> where
82888289
82898290 // TODO(splicing): check for quiescence
82908291
8291- 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- }
8299-
83008292 if our_funding_contribution_satoshis < 0 {
83018293 return Err(ChannelError::Warn(format!(
83028294 "TODO(splicing): Splice-out not supported, only splice in, contribution {}",
83038295 our_funding_contribution_satoshis,
83048296 )));
83058297 }
83068298
8299+ // TODO(splicing): Once splice-out is supported, check that channel balance does not go below 0
8300+ // (or below channel reserve)
8301+
83078302 // Note: post-splice channel value is not yet known at this point, counterparty contribution is not known
83088303 // (Cannot test for miminum required post-splice channel value)
83098304
@@ -8346,27 +8341,18 @@ impl<SP: Deref> FundedChannel<SP> where
83468341 return Err(ChannelError::close("Got splice_init when channel was not in an operational state".to_owned()));
83478342 }
83488343
8349- 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- }
8360-
83618344 if their_funding_contribution_satoshis.saturating_add(our_funding_contribution_satoshis) < 0 {
83628345 return Err(ChannelError::Warn(format!(
83638346 "Splice-out not supported, only splice in, relative {} + {}",
83648347 their_funding_contribution_satoshis, our_funding_contribution_satoshis,
83658348 )));
83668349 }
83678350
8351+ // TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
8352+ // similarly to the check in `splice_channel`.
8353+
83688354 // 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.
8355+ // it can't go below reserve, therefore no pre-check is done here.
83708356 // TODO(splicing): Once splice acceptor can contribute, add reserve pre-check, similar to the one in `splice_ack`.
83718357
83728358 // TODO(splicing): Store msg.funding_pubkey
@@ -12645,7 +12631,6 @@ mod tests {
1264512631
1264612632 // higher fee rate, does not cover
1264712633 {
12648- let expected_fee: u64 = 1948;
1264912634 let res = check_v2_funding_inputs_sufficient(
1265012635 298032,
1265112636 &[
0 commit comments