Skip to content

Commit 8adfa9b

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 f1feac5 commit 8adfa9b

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
@@ -5499,30 +5499,6 @@ where
54995499
self.get_initial_counterparty_commitment_signature(funding, logger)
55005500
}
55015501

5502-
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5503-
let minimum_depth = funding
5504-
.minimum_depth_override
5505-
.or(self.minimum_depth)
5506-
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
5507-
5508-
// Zero-conf channels always meet the minimum depth.
5509-
if minimum_depth == 0 {
5510-
return true;
5511-
}
5512-
5513-
if funding.funding_tx_confirmation_height == 0 {
5514-
return false;
5515-
}
5516-
5517-
let funding_tx_confirmations =
5518-
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5519-
if funding_tx_confirmations < minimum_depth as i64 {
5520-
return false;
5521-
}
5522-
5523-
return true;
5524-
}
5525-
55265502
#[rustfmt::skip]
55275503
fn check_for_funding_tx_confirmed(
55285504
&mut self, funding: &mut FundingScope, block_hash: &BlockHash, height: u32,
@@ -8905,7 +8881,7 @@ where
89058881
// Called:
89068882
// * always when a new block/transactions are confirmed with the new height
89078883
// * when funding is signed with a height of 0
8908-
if !self.context.check_funding_meets_minimum_depth(&self.funding, height) {
8884+
if !self.check_funding_meets_minimum_depth(&self.funding, height) {
89098885
return None;
89108886
}
89118887

@@ -8979,7 +8955,7 @@ where
89798955
fn check_get_splice_locked(
89808956
&self, pending_splice: &PendingSplice, funding: &FundingScope, height: u32,
89818957
) -> Option<msgs::SpliceLocked> {
8982-
if !self.context.check_funding_meets_minimum_depth(funding, height) {
8958+
if !self.check_funding_meets_minimum_depth(funding, height) {
89838959
return None;
89848960
}
89858961

@@ -9000,6 +8976,30 @@ where
90008976
}
90018977
}
90028978

8979+
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
8980+
let minimum_depth = funding
8981+
.minimum_depth_override
8982+
.or(self.context.minimum_depth)
8983+
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
8984+
8985+
// Zero-conf channels always meet the minimum depth.
8986+
if minimum_depth == 0 {
8987+
return true;
8988+
}
8989+
8990+
if funding.funding_tx_confirmation_height == 0 {
8991+
return false;
8992+
}
8993+
8994+
let funding_tx_confirmations =
8995+
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
8996+
if funding_tx_confirmations < minimum_depth as i64 {
8997+
return false;
8998+
}
8999+
9000+
return true;
9001+
}
9002+
90039003
#[cfg(splicing)]
90049004
fn maybe_promote_splice_funding<L: Deref>(
90059005
&mut self, splice_txid: Txid, confirmed_funding_index: usize, logger: &L,

0 commit comments

Comments
 (0)