@@ -10699,44 +10699,6 @@ where
10699
10699
))
10700
10700
}
10701
10701
10702
- /// Check that post-splicing balance meets reserve requirements, but only if it met it pre-splice as well.
10703
- /// In case of error, it returns the minimum channel reserve that was violated (in sats)
10704
- #[cfg(splicing)]
10705
- pub fn check_splice_balance_meets_v2_reserve_requirement(
10706
- &self, pre_balance_msat: u64, post_balance_msat: u64, pre_channel_value_sats: u64,
10707
- post_channel_value_sats: u64, dust_limit_sats: u64,
10708
- ) -> Result<(), u64> {
10709
- let post_channel_reserve_sats =
10710
- get_v2_channel_reserve_satoshis(post_channel_value_sats, dust_limit_sats);
10711
- if post_balance_msat >= (post_channel_reserve_sats * 1000) {
10712
- return Ok(());
10713
- }
10714
- // We're not allowed to dip below the reserve once we've been above,
10715
- // check differently for originally v1 and v2 channels
10716
- if self.is_v2_established() {
10717
- let pre_channel_reserve_sats =
10718
- get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
10719
- if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
10720
- return Err(post_channel_reserve_sats);
10721
- }
10722
- } else {
10723
- if pre_balance_msat >= (self.funding.holder_selected_channel_reserve_satoshis * 1000) {
10724
- return Err(post_channel_reserve_sats);
10725
- }
10726
- if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10727
- if pre_balance_msat >= (cp_reserve * 1000) {
10728
- return Err(post_channel_reserve_sats);
10729
- }
10730
- }
10731
- }
10732
- // Make sure we either remain with the same balance or move towards the reserve.
10733
- if post_balance_msat >= pre_balance_msat {
10734
- Ok(())
10735
- } else {
10736
- Err(post_channel_reserve_sats)
10737
- }
10738
- }
10739
-
10740
10702
/// Check that balances (self and counterparty) meet the channel reserve requirements or violates them (below reserve).
10741
10703
/// The channel value is an input as opposed to using from the FundingScope, so that this can be used in case of splicing
10742
10704
/// to check with new channel value (before being committed to it).
@@ -10775,6 +10737,44 @@ where
10775
10737
Ok(())
10776
10738
}
10777
10739
10740
+ /// Check that post-splicing balance meets reserve requirements, but only if it met it pre-splice as well.
10741
+ /// In case of error, it returns the minimum channel reserve that was violated (in sats)
10742
+ #[cfg(splicing)]
10743
+ pub fn check_splice_balance_meets_v2_reserve_requirement(
10744
+ &self, pre_balance_msat: u64, post_balance_msat: u64, pre_channel_value_sats: u64,
10745
+ post_channel_value_sats: u64, dust_limit_sats: u64,
10746
+ ) -> Result<(), u64> {
10747
+ let post_channel_reserve_sats =
10748
+ get_v2_channel_reserve_satoshis(post_channel_value_sats, dust_limit_sats);
10749
+ if post_balance_msat >= (post_channel_reserve_sats * 1000) {
10750
+ return Ok(());
10751
+ }
10752
+ // We're not allowed to dip below the reserve once we've been above,
10753
+ // check differently for originally v1 and v2 channels
10754
+ if self.is_v2_established() {
10755
+ let pre_channel_reserve_sats =
10756
+ get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
10757
+ if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
10758
+ return Err(post_channel_reserve_sats);
10759
+ }
10760
+ } else {
10761
+ if pre_balance_msat >= (self.funding.holder_selected_channel_reserve_satoshis * 1000) {
10762
+ return Err(post_channel_reserve_sats);
10763
+ }
10764
+ if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10765
+ if pre_balance_msat >= (cp_reserve * 1000) {
10766
+ return Err(post_channel_reserve_sats);
10767
+ }
10768
+ }
10769
+ }
10770
+ // Make sure we either remain with the same balance or move towards the reserve.
10771
+ if post_balance_msat >= pre_balance_msat {
10772
+ Ok(())
10773
+ } else {
10774
+ Err(post_channel_reserve_sats)
10775
+ }
10776
+ }
10777
+
10778
10778
// Send stuff to our remote peers:
10779
10779
10780
10780
/// Queues up an outbound HTLC to send by placing it in the holding cell. You should call
0 commit comments