Skip to content

Commit 47f4737

Browse files
committed
fix Handle originally-v1 channel pre-splice reserve specially
1 parent 8919039 commit 47f4737

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
@@ -8639,10 +8639,22 @@ impl<SP: Deref> FundedChannel<SP> where
86398639
if post_balance >= post_channel_reserve_sats * 1000 {
86408640
return Ok(());
86418641
}
8642-
let pre_channel_reserve_sats = get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
8643-
if pre_balance >= pre_channel_reserve_sats * 1000 {
8644-
// We're not allowed to dip below the reserve once we've been above.
8645-
return Err(post_channel_reserve_sats);
8642+
// We're not allowed to dip below the reserve once we've been above,
8643+
// check differently for originally v1 and v2 channels
8644+
if self.is_v2_established {
8645+
let pre_channel_reserve_sats = get_v2_channel_reserve_satoshis(pre_channel_value, dust_limit);
8646+
if pre_balance >= pre_channel_reserve_sats * 1000 {
8647+
return Err(post_channel_reserve_sats);
8648+
}
8649+
} else {
8650+
if pre_balance >= self.funding.holder_selected_channel_reserve_satoshis * 1000 {
8651+
return Err(post_channel_reserve_sats);
8652+
}
8653+
if let Some(cp_reserve) = self.funding.counterparty_selected_channel_reserve_satoshis {
8654+
if pre_balance >= cp_reserve * 1000 {
8655+
return Err(post_channel_reserve_sats);
8656+
}
8657+
}
86468658
}
86478659
// Make sure we either remain with the same balance or move towards the reserve.
86488660
if post_balance >= pre_balance {

0 commit comments

Comments
 (0)