From 7f29adbba1edf0b784e698befbaa42cb4dd0f082 Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:58:22 +0100 Subject: [PATCH] Comments; reg. reserve check; review --- lightning/src/ln/channel.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 62487b6e116..cfa4f467e54 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -8151,7 +8151,8 @@ impl FundedChannel where // Note: post-splice channel value is not yet known at this point, counterparty contribution is not known // (Cannot test for miminum required post-splice channel value) - // Check that inputs are sufficient to cover our contribution + // Pre-check that inputs are sufficient to cover our contribution. + // Note: fees are not taken into account here. let sum_input: i64 = our_funding_inputs.into_iter().map( |(txin, tx)| tx.output.get(txin.previous_output.vout as usize).map(|tx| tx.value.to_sat() as i64).unwrap_or(0) ).sum(); @@ -8208,11 +8209,9 @@ impl FundedChannel where ))); } - let post_channel_value = PendingSplice::compute_post_value(pre_channel_value, their_funding_contribution_satoshis, our_funding_contribution_satoshis); - let post_balance = PendingSplice::add_checked(self.context.value_to_self_msat, our_funding_contribution_satoshis); - // Early check for reserve requirement, assuming maximum balance of full channel value - // This will also be checked later at tx_complete - let _res = self.context.check_balance_meets_v2_reserve_requirements(post_balance, post_channel_value)?; + // Note on channel reserve requirement pre-check: as the splice acceptor does not contribute, + // it can go below reserve, therefore no pre-check is done here. + // TODO(splicing): Once splice acceptor can contribute, add reserve pre-check, similar to the one in `splice_ack`. // TODO(splicing): Store msg.funding_pubkey // TODO(splicing): Apply start of splice (splice_start) @@ -8239,7 +8238,7 @@ impl FundedChannel where let pre_channel_value = self.context.get_value_satoshis(); let post_channel_value = PendingSplice::compute_post_value(pre_channel_value, our_funding_contribution, their_funding_contribution_satoshis); let post_balance = PendingSplice::add_checked(self.context.value_to_self_msat, our_funding_contribution); - // Early check for reserve requirement, assuming maximum balance of full channel value + // Pre-check for reserve requirement, assuming maximum balance of full channel value // This will also be checked later at tx_complete let _res = self.context.check_balance_meets_v2_reserve_requirements(post_balance, post_channel_value)?; Ok(())