Skip to content

Commit c78211b

Browse files
committed
fix Use v2 reserve condition for spliced-from-v1 v2 channels as well
1 parent ecf097a commit c78211b

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
@@ -10751,7 +10753,7 @@ where
1075110753
}
1075210754
// We're not allowed to dip below the reserve once we've been above,
1075310755
// check differently for originally v1 and v2 channels
10754-
if self.is_v2_established() {
10756+
if self.is_v2() {
1075510757
let pre_channel_reserve_sats =
1075610758
get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
1075710759
if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
@@ -11599,6 +11601,18 @@ where
1159911601
// CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY confirmations.
1160011602
self.context.historical_scids.drain(0..end)
1160111603
}
11604+
11605+
/// Check is channel is currently v2:
11606+
/// - established as v2
11607+
/// - or past a splice (which implicitly makes the channel v2)
11608+
#[cfg(splicing)]
11609+
fn is_v2(&self) -> bool {
11610+
if self.funding.channel_transaction_parameters.splice_parent_funding_txid.is_some() {
11611+
true
11612+
} else {
11613+
self.is_v2_established()
11614+
}
11615+
}
1160211616
}
1160311617

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

0 commit comments

Comments
 (0)