File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -8639,10 +8639,22 @@ impl<SP: Deref> FundedChannel<SP> where
8639
8639
if post_balance >= post_channel_reserve_sats * 1000 {
8640
8640
return Ok(());
8641
8641
}
8642
- let pre_channel_reserve_sats = get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
8643
- if pre_balance >= pre_channel_reserve_sats * 1000 {
8644
- // We're not allowed to dip below the reserve once we've been above.
8645
- return Err(post_channel_reserve_sats);
8642
+ // We're not allowed to dip below the reserve once we've been above,
8643
+ // check differently for originally v1 and v2 channels
8644
+ if self.is_v2_established {
8645
+ let pre_channel_reserve_sats = get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
8646
+ if pre_balance >= pre_channel_reserve_sats * 1000 {
8647
+ return Err(post_channel_reserve_sats);
8648
+ }
8649
+ } else {
8650
+ if pre_balance >= self.funding.holder_selected_channel_reserve_satoshis * 1000 {
8651
+ return Err(post_channel_reserve_sats);
8652
+ }
8653
+ if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
8654
+ if pre_balance >= cp_reserve * 1000 {
8655
+ return Err(post_channel_reserve_sats);
8656
+ }
8657
+ }
8646
8658
}
8647
8659
// Make sure we either remain with the same balance or move towards the reserve.
8648
8660
if post_balance >= pre_balance {
You can’t perform that action at this time.
0 commit comments