Skip to content

Commit 91873da

Browse files
committed
fix Use v2 reserve condition for spliced-from-v1 v2 channels as well
1 parent 6ebc0bd commit 91873da

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
@@ -2764,6 +2764,8 @@ where
27642764
"commitment_signed"
27652765
}
27662766

2767+
/// Checks whether the channel was opened through V2 channel open (negotiation).
2768+
/// See also: is_v2()
27672769
fn is_v2_established(&self) -> bool {
27682770
let channel_parameters = &self.funding().channel_transaction_parameters;
27692771
// This will return false if `counterparty_parameters` is `None`, but for a `FundedChannel`, it
@@ -10569,7 +10571,7 @@ where
1056910571
}
1057010572
// We're not allowed to dip below the reserve once we've been above,
1057110573
// check differently for originally v1 and v2 channels
10572-
if self.is_v2_established() {
10574+
if self.is_v2() {
1057310575
let pre_channel_reserve_sats =
1057410576
get_v2_channel_reserve_satoshis(pre_channel_value_sats, dust_limit_sats);
1057510577
if pre_balance_msat >= (pre_channel_reserve_sats * 1000) {
@@ -11385,6 +11387,18 @@ where
1138511387
// CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY confirmations.
1138611388
self.context.historical_scids.drain(0..end)
1138711389
}
11390+
11391+
/// Check is channel is currently v2:
11392+
/// - established as v2
11393+
/// - or past a splice (which implicitly makes the channel v2)
11394+
#[cfg(splicing)]
11395+
fn is_v2(&self) -> bool {
11396+
if self.funding.channel_transaction_parameters.splice_parent_funding_txid.is_some() {
11397+
true
11398+
} else {
11399+
self.is_v2_established()
11400+
}
11401+
}
1138811402
}
1138911403

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

0 commit comments

Comments
 (0)