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 @@ -10507,10 +10507,22 @@ where
1050710507 if post_balance >= post_channel_reserve_sats * 1000 {
1050810508 return Ok(());
1050910509 }
10510- let pre_channel_reserve_sats = get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
10511- if pre_balance >= pre_channel_reserve_sats * 1000 {
10512- // We're not allowed to dip below the reserve once we've been above.
10513- return Err(post_channel_reserve_sats);
10510+ // We're not allowed to dip below the reserve once we've been above,
10511+ // check differently for originally v1 and v2 channels
10512+ if self.is_v2_established() {
10513+ let pre_channel_reserve_sats = get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
10514+ if pre_balance >= pre_channel_reserve_sats * 1000 {
10515+ return Err(post_channel_reserve_sats);
10516+ }
10517+ } else {
10518+ if pre_balance >= self.funding.holder_selected_channel_reserve_satoshis * 1000 {
10519+ return Err(post_channel_reserve_sats);
10520+ }
10521+ if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10522+ if pre_balance >= cp_reserve * 1000 {
10523+ return Err(post_channel_reserve_sats);
10524+ }
10525+ }
1051410526 }
1051510527 // Make sure we either remain with the same balance or move towards the reserve.
1051610528 if post_balance >= pre_balance {
You can’t perform that action at this time.
0 commit comments