Skip to content

Commit 7fee3bf

Browse files
committed
fix Use v2 reserve condition for spliced-from-v1 v2 channels as well
1 parent 5cc94ee commit 7fee3bf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,6 +2757,8 @@ where
27572757
"commitment_signed"
27582758
}
27592759

2760+
/// Checks whether the channel was opened through V2 channel open (negotiation).
2761+
/// See also: is_v2()
27602762
fn is_v2_established(&self) -> bool {
27612763
let channel_parameters = &self.funding().channel_transaction_parameters;
27622764
// This will return false if `counterparty_parameters` is `None`, but for a `FundedChannel`, it
@@ -10759,7 +10761,7 @@ where
1075910761
}
1076010762
// We're not allowed to dip below the reserve once we've been above,
1076110763
// check differently for originally v1 and v2 channels
10762-
if self.is_v2_established() {
10764+
if self.is_v2() {
1076310765
let pre_channel_reserve_sats =
1076410766
get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
1076510767
if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
@@ -11575,6 +11577,18 @@ where
1157511577
// CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY confirmations.
1157611578
self.context.historical_scids.drain(0..end)
1157711579
}
11580+
11581+
/// Check is channel is currently v2:
11582+
/// - established as v2
11583+
/// - or past a splice (which implicitly makes the channel v2)
11584+
#[cfg(splicing)]
11585+
fn is_v2(&self) -> bool {
11586+
if self.funding.channel_transaction_parameters.splice_parent_funding_txid.is_some() {
11587+
true
11588+
} else {
11589+
self.is_v2_established()
11590+
}
11591+
}
1157811592
}
1157911593

1158011594
/// A not-yet-funded outbound (from holder) channel using V1 channel establishment.

0 commit comments

Comments
 (0)