Skip to content

Commit 614c5db

Browse files
committed
Comments; reg. reserve check; review
1 parent 518892d commit 614c5db

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8151,7 +8151,8 @@ impl<SP: Deref> FundedChannel<SP> where
81518151
// Note: post-splice channel value is not yet known at this point, counterparty contribution is not known
81528152
// (Cannot test for miminum required post-splice channel value)
81538153

8154-
// Check that inputs are sufficient to cover our contribution
8154+
// Pre-check that inputs are sufficient to cover our contribution.
8155+
// Note: fees are not taken into account here.
81558156
let sum_input: i64 = our_funding_inputs.into_iter().map(
81568157
|(txin, tx)| tx.output.get(txin.previous_output.vout as usize).map(|tx| tx.value.to_sat() as i64).unwrap_or(0)
81578158
).sum();
@@ -8208,11 +8209,9 @@ impl<SP: Deref> FundedChannel<SP> where
82088209
)));
82098210
}
82108211

8211-
let post_channel_value = PendingSplice::compute_post_value(pre_channel_value, their_funding_contribution_satoshis, our_funding_contribution_satoshis);
8212-
let post_balance = PendingSplice::add_checked(self.context.value_to_self_msat, our_funding_contribution_satoshis);
8213-
// Early check for reserve requirement, assuming maximum balance of full channel value
8214-
// This will also be checked later at tx_complete
8215-
let _res = self.context.check_balance_meets_v2_reserve_requirements(post_balance, post_channel_value)?;
8212+
// Note on channel reserve requirement pre-check: as the splice acceptor does not contribute,
8213+
// it can go below reserve, therefore no pre-check is done here.
8214+
// TODO(splicing): Once splice acceptor can contribute, add reserve pre-check, similar to the one in `splice_ack`.
82168215

82178216
// TODO(splicing): Store msg.funding_pubkey
82188217
// TODO(splicing): Apply start of splice (splice_start)
@@ -8239,7 +8238,7 @@ impl<SP: Deref> FundedChannel<SP> where
82398238
let pre_channel_value = self.context.get_value_satoshis();
82408239
let post_channel_value = PendingSplice::compute_post_value(pre_channel_value, our_funding_contribution, their_funding_contribution_satoshis);
82418240
let post_balance = PendingSplice::add_checked(self.context.value_to_self_msat, our_funding_contribution);
8242-
// Early check for reserve requirement, assuming maximum balance of full channel value
8241+
// Pre-check for reserve requirement, assuming maximum balance of full channel value
82438242
// This will also be checked later at tx_complete
82448243
let _res = self.context.check_balance_meets_v2_reserve_requirements(post_balance, post_channel_value)?;
82458244
Ok(())

0 commit comments

Comments
 (0)