Skip to content

Commit bb405d6

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 1b3d6b1 commit bb405d6

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

lightning/src/ln/channel.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,28 +5301,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
53015301
self.get_initial_counterparty_commitment_signature(funding, logger)
53025302
}
53035303

5304-
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5305-
let minimum_depth = funding.minimum_depth_override
5306-
.or(self.minimum_depth)
5307-
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
5308-
5309-
// Zero-conf channels always meet the minimum depth.
5310-
if minimum_depth == 0 {
5311-
return true;
5312-
}
5313-
5314-
if funding.funding_tx_confirmation_height == 0 {
5315-
return false;
5316-
}
5317-
5318-
let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5319-
if funding_tx_confirmations < minimum_depth as i64 {
5320-
return false;
5321-
}
5322-
5323-
return true;
5324-
}
5325-
53265304
fn check_for_funding_tx_confirmed(
53275305
&mut self, funding: &mut FundingScope, block_hash: &BlockHash, height: u32,
53285306
index_in_block: usize, tx: &mut ConfirmedTransaction,
@@ -8625,7 +8603,7 @@ impl<SP: Deref> FundedChannel<SP> where
86258603
// Called:
86268604
// * always when a new block/transactions are confirmed with the new height
86278605
// * when funding is signed with a height of 0
8628-
if !self.context.check_funding_meets_minimum_depth(&self.funding, height) {
8606+
if !self.check_funding_meets_minimum_depth(&self.funding, height) {
86298607
return None;
86308608
}
86318609

@@ -8698,7 +8676,7 @@ impl<SP: Deref> FundedChannel<SP> where
86988676
fn check_get_splice_locked(
86998677
&self, pending_splice: &PendingSplice, funding: &FundingScope, height: u32,
87008678
) -> Option<msgs::SpliceLocked> {
8701-
if !self.context.check_funding_meets_minimum_depth(funding, height) {
8679+
if !self.check_funding_meets_minimum_depth(funding, height) {
87028680
return None;
87038681
}
87048682

@@ -8721,6 +8699,28 @@ impl<SP: Deref> FundedChannel<SP> where
87218699
}
87228700
}
87238701

8702+
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
8703+
let minimum_depth = funding.minimum_depth_override
8704+
.or(self.context.minimum_depth)
8705+
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
8706+
8707+
// Zero-conf channels always meet the minimum depth.
8708+
if minimum_depth == 0 {
8709+
return true;
8710+
}
8711+
8712+
if funding.funding_tx_confirmation_height == 0 {
8713+
return false;
8714+
}
8715+
8716+
let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
8717+
if funding_tx_confirmations < minimum_depth as i64 {
8718+
return false;
8719+
}
8720+
8721+
return true;
8722+
}
8723+
87248724
#[cfg(splicing)]
87258725
fn maybe_promote_splice_funding<L: Deref>(
87268726
&mut self, splice_txid: Txid, confirmed_funding_index: usize, logger: &L,

0 commit comments

Comments
 (0)