Skip to content

Commit c69a2cb

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

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
@@ -2761,6 +2761,8 @@ where
27612761
"commitment_signed"
27622762
}
27632763

2764+
/// Checks whether the channel was opened through V2 channel open (negotiation).
2765+
/// See also: is_v2()
27642766
fn is_v2_established(&self) -> bool {
27652767
let channel_parameters = &self.funding().channel_transaction_parameters;
27662768
// This will return false if `counterparty_parameters` is `None`, but for a `FundedChannel`, it
@@ -10591,7 +10593,7 @@ where
1059110593
}
1059210594
// We're not allowed to dip below the reserve once we've been above,
1059310595
// check differently for originally v1 and v2 channels
10594-
if self.is_v2_established() {
10596+
if self.is_v2() {
1059510597
let pre_channel_reserve_sats =
1059610598
get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
1059710599
if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
@@ -11386,6 +11388,18 @@ where
1138611388
// CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY confirmations.
1138711389
self.context.historical_scids.drain(0..end)
1138811390
}
11391+
11392+
/// Check is channel is currently v2:
11393+
/// - established as v2
11394+
/// - or past a splice (which implicitly makes the channel v2)
11395+
#[cfg(splicing)]
11396+
fn is_v2(&self) -> bool {
11397+
if self.funding.channel_transaction_parameters.splice_parent_funding_txid.is_some() {
11398+
true
11399+
} else {
11400+
self.is_v2_established()
11401+
}
11402+
}
1138911403
}
1139011404

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

0 commit comments

Comments
 (0)