@@ -10539,44 +10539,6 @@ where
10539
10539
Ok((None, None))
10540
10540
}
10541
10541
10542
- /// Check that post-splicing balance meets reserve requirements, but only if it met it pre-splice as well.
10543
- /// In case of error, it returns the minimum channel reserve that was violated (in sats)
10544
- #[cfg(splicing)]
10545
- pub fn check_splice_balance_meets_v2_reserve_requirement(
10546
- &self, pre_balance_msat: u64, post_balance_msat: u64, pre_channel_value_sats: u64,
10547
- post_channel_value_sats: u64, dust_limit_sats: u64,
10548
- ) -> Result<(), u64> {
10549
- let post_channel_reserve_sats =
10550
- get_v2_channel_reserve_satoshis(post_channel_value_sats, dust_limit_sats);
10551
- if post_balance_msat >= (post_channel_reserve_sats * 1000) {
10552
- return Ok(());
10553
- }
10554
- // We're not allowed to dip below the reserve once we've been above,
10555
- // check differently for originally v1 and v2 channels
10556
- if self.is_v2_established() {
10557
- let pre_channel_reserve_sats =
10558
- get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
10559
- if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
10560
- return Err(post_channel_reserve_sats);
10561
- }
10562
- } else {
10563
- if pre_balance_msat >= (self.funding.holder_selected_channel_reserve_satoshis * 1000) {
10564
- return Err(post_channel_reserve_sats);
10565
- }
10566
- if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10567
- if pre_balance_msat >= (cp_reserve * 1000) {
10568
- return Err(post_channel_reserve_sats);
10569
- }
10570
- }
10571
- }
10572
- // Make sure we either remain with the same balance or move towards the reserve.
10573
- if post_balance_msat >= pre_balance_msat {
10574
- Ok(())
10575
- } else {
10576
- Err(post_channel_reserve_sats)
10577
- }
10578
- }
10579
-
10580
10542
/// Check that balances (self and counterparty) meet the channel reserve requirements or violates them (below reserve).
10581
10543
/// The channel value is an input as opposed to using from the FundingScope, so that this can be used in case of splicing
10582
10544
/// to check with new channel value (before being committed to it).
@@ -10615,6 +10577,44 @@ where
10615
10577
Ok(())
10616
10578
}
10617
10579
10580
+ /// Check that post-splicing balance meets reserve requirements, but only if it met it pre-splice as well.
10581
+ /// In case of error, it returns the minimum channel reserve that was violated (in sats)
10582
+ #[cfg(splicing)]
10583
+ pub fn check_splice_balance_meets_v2_reserve_requirement(
10584
+ &self, pre_balance_msat: u64, post_balance_msat: u64, pre_channel_value_sats: u64,
10585
+ post_channel_value_sats: u64, dust_limit_sats: u64,
10586
+ ) -> Result<(), u64> {
10587
+ let post_channel_reserve_sats =
10588
+ get_v2_channel_reserve_satoshis(post_channel_value_sats, dust_limit_sats);
10589
+ if post_balance_msat >= (post_channel_reserve_sats * 1000) {
10590
+ return Ok(());
10591
+ }
10592
+ // We're not allowed to dip below the reserve once we've been above,
10593
+ // check differently for originally v1 and v2 channels
10594
+ if self.is_v2_established() {
10595
+ let pre_channel_reserve_sats =
10596
+ get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
10597
+ if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
10598
+ return Err(post_channel_reserve_sats);
10599
+ }
10600
+ } else {
10601
+ if pre_balance_msat >= (self.funding.holder_selected_channel_reserve_satoshis * 1000) {
10602
+ return Err(post_channel_reserve_sats);
10603
+ }
10604
+ if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10605
+ if pre_balance_msat >= (cp_reserve * 1000) {
10606
+ return Err(post_channel_reserve_sats);
10607
+ }
10608
+ }
10609
+ }
10610
+ // Make sure we either remain with the same balance or move towards the reserve.
10611
+ if post_balance_msat >= pre_balance_msat {
10612
+ Ok(())
10613
+ } else {
10614
+ Err(post_channel_reserve_sats)
10615
+ }
10616
+ }
10617
+
10618
10618
// Send stuff to our remote peers:
10619
10619
10620
10620
/// Queues up an outbound HTLC to send by placing it in the holding cell. You should call
0 commit comments