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 @@ -10548,11 +10548,23 @@ where
1054810548 if post_balance >= post_channel_reserve_sats * 1000 {
1054910549 return Ok(());
1055010550 }
10551- let pre_channel_reserve_sats =
10552- get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
10553- if pre_balance >= pre_channel_reserve_sats * 1000 {
10554- // We're not allowed to dip below the reserve once we've been above.
10555- return Err(post_channel_reserve_sats);
10551+ // We're not allowed to dip below the reserve once we've been above,
10552+ // check differently for originally v1 and v2 channels
10553+ if self.is_v2_established() {
10554+ let pre_channel_reserve_sats =
10555+ get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
10556+ if pre_balance >= pre_channel_reserve_sats * 1000 {
10557+ return Err(post_channel_reserve_sats);
10558+ }
10559+ } else {
10560+ if pre_balance >= self.funding.holder_selected_channel_reserve_satoshis * 1000 {
10561+ return Err(post_channel_reserve_sats);
10562+ }
10563+ if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10564+ if pre_balance >= cp_reserve * 1000 {
10565+ return Err(post_channel_reserve_sats);
10566+ }
10567+ }
1055610568 }
1055710569 // Make sure we either remain with the same balance or move towards the reserve.
1055810570 if post_balance >= pre_balance {
You can’t perform that action at this time.
0 commit comments