Skip to content

Commit 858ded0

Browse files
committed
fix Use v2 reserve condition for spliced-from-v1 v2 channels as well
1 parent af1b8eb commit 858ded0

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
@@ -2996,6 +2996,8 @@ where
29962996
"commitment_signed"
29972997
}
29982998

2999+
/// Checks whether the channel was opened through V2 channel open (negotiation).
3000+
/// See also: is_v2()
29993001
fn is_v2_established(&self) -> bool {
30003002
let channel_parameters = &self.funding().channel_transaction_parameters;
30013003
// This will return false if `counterparty_parameters` is `None`, but for a `FundedChannel`, it
@@ -11144,7 +11146,7 @@ where
1114411146
}
1114511147
// We're not allowed to dip below the reserve once we've been above,
1114611148
// check differently for originally v1 and v2 channels
11147-
if self.is_v2_established() {
11149+
if self.is_v2() {
1114811150
let pre_channel_reserve_sats =
1114911151
get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
1115011152
if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
@@ -11992,6 +11994,18 @@ where
1199211994
// CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY confirmations.
1199311995
self.context.historical_scids.drain(0..end)
1199411996
}
11997+
11998+
/// Check is channel is currently v2:
11999+
/// - established as v2
12000+
/// - or past a splice (which implicitly makes the channel v2)
12001+
#[cfg(splicing)]
12002+
fn is_v2(&self) -> bool {
12003+
if self.funding.channel_transaction_parameters.splice_parent_funding_txid.is_some() {
12004+
true
12005+
} else {
12006+
self.is_v2_established()
12007+
}
12008+
}
1199512009
}
1199612010

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

0 commit comments

Comments
 (0)