Skip to content

Commit 4325faf

Browse files
committed
Move check_funding_meets_minimum_depth to FundedChannel
This method is only applicable for FundedChannel, so it shouldn't be accessible from ChannelContext.
1 parent 0518017 commit 4325faf

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

lightning/src/ln/channel.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5511,30 +5511,6 @@ where
55115511
self.get_initial_counterparty_commitment_signature(funding, logger)
55125512
}
55135513

5514-
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5515-
let minimum_depth = funding
5516-
.minimum_depth_override
5517-
.or(self.minimum_depth)
5518-
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
5519-
5520-
// Zero-conf channels always meet the minimum depth.
5521-
if minimum_depth == 0 {
5522-
return true;
5523-
}
5524-
5525-
if funding.funding_tx_confirmation_height == 0 {
5526-
return false;
5527-
}
5528-
5529-
let funding_tx_confirmations =
5530-
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5531-
if funding_tx_confirmations < minimum_depth as i64 {
5532-
return false;
5533-
}
5534-
5535-
return true;
5536-
}
5537-
55385514
#[rustfmt::skip]
55395515
fn check_for_funding_tx_confirmed(
55405516
&mut self, funding: &mut FundingScope, block_hash: &BlockHash, height: u32,
@@ -8949,7 +8925,7 @@ where
89498925
// Called:
89508926
// * always when a new block/transactions are confirmed with the new height
89518927
// * when funding is signed with a height of 0
8952-
if !self.context.check_funding_meets_minimum_depth(&self.funding, height) {
8928+
if !self.check_funding_meets_minimum_depth(&self.funding, height) {
89538929
return None;
89548930
}
89558931

@@ -9023,7 +8999,7 @@ where
90238999
fn check_get_splice_locked(
90249000
&self, pending_splice: &PendingSplice, funding: &FundingScope, height: u32,
90259001
) -> Option<msgs::SpliceLocked> {
9026-
if !self.context.check_funding_meets_minimum_depth(funding, height) {
9002+
if !self.check_funding_meets_minimum_depth(funding, height) {
90279003
return None;
90289004
}
90299005

@@ -9044,6 +9020,30 @@ where
90449020
}
90459021
}
90469022

9023+
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
9024+
let minimum_depth = funding
9025+
.minimum_depth_override
9026+
.or(self.context.minimum_depth)
9027+
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
9028+
9029+
// Zero-conf channels always meet the minimum depth.
9030+
if minimum_depth == 0 {
9031+
return true;
9032+
}
9033+
9034+
if funding.funding_tx_confirmation_height == 0 {
9035+
return false;
9036+
}
9037+
9038+
let funding_tx_confirmations =
9039+
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
9040+
if funding_tx_confirmations < minimum_depth as i64 {
9041+
return false;
9042+
}
9043+
9044+
return true;
9045+
}
9046+
90479047
#[cfg(splicing)]
90489048
fn maybe_promote_splice_funding<L: Deref>(
90499049
&mut self, splice_txid: Txid, confirmed_funding_index: usize, logger: &L,

0 commit comments

Comments
 (0)