File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -11099,11 +11099,23 @@ where
11099
11099
if post_balance >= post_channel_reserve_sats * 1000 {
11100
11100
return Ok(());
11101
11101
}
11102
- let pre_channel_reserve_sats =
11103
- get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
11104
- if pre_balance >= pre_channel_reserve_sats * 1000 {
11105
- // We're not allowed to dip below the reserve once we've been above.
11106
- return Err(post_channel_reserve_sats);
11102
+ // We're not allowed to dip below the reserve once we've been above,
11103
+ // check differently for originally v1 and v2 channels
11104
+ if self.is_v2_established() {
11105
+ let pre_channel_reserve_sats =
11106
+ get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
11107
+ if pre_balance >= pre_channel_reserve_sats * 1000 {
11108
+ return Err(post_channel_reserve_sats);
11109
+ }
11110
+ } else {
11111
+ if pre_balance >= self.funding.holder_selected_channel_reserve_satoshis * 1000 {
11112
+ return Err(post_channel_reserve_sats);
11113
+ }
11114
+ if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
11115
+ if pre_balance >= cp_reserve * 1000 {
11116
+ return Err(post_channel_reserve_sats);
11117
+ }
11118
+ }
11107
11119
}
11108
11120
// Make sure we either remain with the same balance or move towards the reserve.
11109
11121
if post_balance >= pre_balance {
You can’t perform that action at this time.
0 commit comments