Skip to content

Commit 83f0465

Browse files
committed
fix Handle originally-v1 channel pre-splice reserve specially
1 parent 31245c3 commit 83f0465

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lightning/src/ln/channel.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10708,11 +10708,23 @@ where
1070810708
if post_balance >= post_channel_reserve_sats * 1000 {
1070910709
return Ok(());
1071010710
}
10711-
let pre_channel_reserve_sats =
10712-
get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
10713-
if pre_balance >= pre_channel_reserve_sats * 1000 {
10714-
// We're not allowed to dip below the reserve once we've been above.
10715-
return Err(post_channel_reserve_sats);
10711+
// We're not allowed to dip below the reserve once we've been above,
10712+
// check differently for originally v1 and v2 channels
10713+
if self.is_v2_established() {
10714+
let pre_channel_reserve_sats =
10715+
get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
10716+
if pre_balance >= pre_channel_reserve_sats * 1000 {
10717+
return Err(post_channel_reserve_sats);
10718+
}
10719+
} else {
10720+
if pre_balance >= self.funding.holder_selected_channel_reserve_satoshis * 1000 {
10721+
return Err(post_channel_reserve_sats);
10722+
}
10723+
if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
10724+
if pre_balance >= cp_reserve * 1000 {
10725+
return Err(post_channel_reserve_sats);
10726+
}
10727+
}
1071610728
}
1071710729
// Make sure we either remain with the same balance or move towards the reserve.
1071810730
if post_balance >= pre_balance {

0 commit comments

Comments
 (0)