Skip to content

Commit eb1fc46

Browse files
committed
fix Handle originally-v1 channel pre-splice reserve specially
1 parent 0a45dfb commit eb1fc46

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)