@@ -5004,43 +5004,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
50045004 self.get_initial_counterparty_commitment_signature(funding, logger)
50055005 }
50065006
5007- fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5008- let minimum_depth = self.minimum_depth
5009- .expect("ChannelContext::minimum_depth should be set for FundedChannel");
5010-
5011- // Zero-conf channels always meet the minimum depth.
5012- if minimum_depth == 0 {
5013- return true;
5014- }
5015-
5016- let is_coinbase = funding
5017- .funding_transaction
5018- .as_ref()
5019- .map(|tx| tx.is_coinbase())
5020- .unwrap_or(false);
5021-
5022- let minimum_depth = {
5023- // If the funding transaction is a coinbase transaction, we need to set the minimum
5024- // depth to 100.
5025- if is_coinbase && minimum_depth < COINBASE_MATURITY {
5026- COINBASE_MATURITY
5027- } else {
5028- minimum_depth
5029- }
5030- };
5031-
5032- if funding.funding_tx_confirmation_height == 0 {
5033- return false;
5034- }
5035-
5036- let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5037- if funding_tx_confirmations < minimum_depth as i64 {
5038- return false;
5039- }
5040-
5041- return true;
5042- }
5043-
50445007 fn check_for_funding_tx_confirmed(
50455008 &mut self, funding: &mut FundingScope, block_hash: &BlockHash, height: u32,
50465009 index_in_block: usize, tx: &mut ConfirmedTransaction,
@@ -8360,7 +8323,7 @@ impl<SP: Deref> FundedChannel<SP> where
83608323 // Called:
83618324 // * always when a new block/transactions are confirmed with the new height
83628325 // * when funding is signed with a height of 0
8363- if !self.context. check_funding_meets_minimum_depth(&self.funding, height) {
8326+ if !self.check_funding_meets_minimum_depth(&self.funding, height) {
83648327 return None;
83658328 }
83668329
@@ -8433,7 +8396,7 @@ impl<SP: Deref> FundedChannel<SP> where
84338396 fn check_get_splice_locked(
84348397 &self, pending_splice: &PendingSplice, funding: &FundingScope, height: u32,
84358398 ) -> Option<msgs::SpliceLocked> {
8436- if !self.context. check_funding_meets_minimum_depth(funding, height) {
8399+ if !self.check_funding_meets_minimum_depth(funding, height) {
84378400 return None;
84388401 }
84398402
@@ -8459,6 +8422,43 @@ impl<SP: Deref> FundedChannel<SP> where
84598422 }
84608423 }
84618424
8425+ fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
8426+ let minimum_depth = self.context.minimum_depth
8427+ .expect("ChannelContext::minimum_depth should be set for FundedChannel");
8428+
8429+ // Zero-conf channels always meet the minimum depth.
8430+ if minimum_depth == 0 {
8431+ return true;
8432+ }
8433+
8434+ let is_coinbase = funding
8435+ .funding_transaction
8436+ .as_ref()
8437+ .map(|tx| tx.is_coinbase())
8438+ .unwrap_or(false);
8439+
8440+ let minimum_depth = {
8441+ // If the funding transaction is a coinbase transaction, we need to set the minimum
8442+ // depth to 100.
8443+ if is_coinbase && minimum_depth < COINBASE_MATURITY {
8444+ COINBASE_MATURITY
8445+ } else {
8446+ minimum_depth
8447+ }
8448+ };
8449+
8450+ if funding.funding_tx_confirmation_height == 0 {
8451+ return false;
8452+ }
8453+
8454+ let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
8455+ if funding_tx_confirmations < minimum_depth as i64 {
8456+ return false;
8457+ }
8458+
8459+ return true;
8460+ }
8461+
84628462 fn maybe_promote_splice_funding(
84638463 &mut self, splice_txid: Txid, confirmed_funding_index: usize,
84648464 ) -> bool {
0 commit comments