@@ -5000,43 +5000,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
50005000 self.get_initial_counterparty_commitment_signature(funding, logger)
50015001 }
50025002
5003- fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5004- let minimum_depth = self.minimum_depth
5005- .expect("ChannelContext::minimum_depth should be set for FundedChannel");
5006-
5007- // Zero-conf channels always meet the minimum depth.
5008- if minimum_depth == 0 {
5009- return true;
5010- }
5011-
5012- let is_coinbase = funding
5013- .funding_transaction
5014- .as_ref()
5015- .map(|tx| tx.is_coinbase())
5016- .unwrap_or(false);
5017-
5018- let minimum_depth = {
5019- // If the funding transaction is a coinbase transaction, we need to set the minimum
5020- // depth to 100.
5021- if is_coinbase && minimum_depth < COINBASE_MATURITY {
5022- COINBASE_MATURITY
5023- } else {
5024- minimum_depth
5025- }
5026- };
5027-
5028- if funding.funding_tx_confirmation_height == 0 {
5029- return false;
5030- }
5031-
5032- let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5033- if funding_tx_confirmations < minimum_depth as i64 {
5034- return false;
5035- }
5036-
5037- return true;
5038- }
5039-
50405003 fn check_for_funding_tx_confirmed(
50415004 &mut self, funding: &mut FundingScope, block_hash: &BlockHash, height: u32,
50425005 index_in_block: usize, tx: &mut ConfirmedTransaction,
@@ -8358,7 +8321,7 @@ impl<SP: Deref> FundedChannel<SP> where
83588321 // Called:
83598322 // * always when a new block/transactions are confirmed with the new height
83608323 // * when funding is signed with a height of 0
8361- if !self.context. check_funding_meets_minimum_depth(&self.funding, height) {
8324+ if !self.check_funding_meets_minimum_depth(&self.funding, height) {
83628325 return None;
83638326 }
83648327
@@ -8431,7 +8394,7 @@ impl<SP: Deref> FundedChannel<SP> where
84318394 fn check_get_splice_locked(
84328395 &self, pending_splice: &PendingSplice, funding: &FundingScope, height: u32,
84338396 ) -> Option<msgs::SpliceLocked> {
8434- if !self.context. check_funding_meets_minimum_depth(funding, height) {
8397+ if !self.check_funding_meets_minimum_depth(funding, height) {
84358398 return None;
84368399 }
84378400
@@ -8457,6 +8420,43 @@ impl<SP: Deref> FundedChannel<SP> where
84578420 }
84588421 }
84598422
8423+ fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
8424+ let minimum_depth = self.context.minimum_depth
8425+ .expect("ChannelContext::minimum_depth should be set for FundedChannel");
8426+
8427+ // Zero-conf channels always meet the minimum depth.
8428+ if minimum_depth == 0 {
8429+ return true;
8430+ }
8431+
8432+ let is_coinbase = funding
8433+ .funding_transaction
8434+ .as_ref()
8435+ .map(|tx| tx.is_coinbase())
8436+ .unwrap_or(false);
8437+
8438+ let minimum_depth = {
8439+ // If the funding transaction is a coinbase transaction, we need to set the minimum
8440+ // depth to 100.
8441+ if is_coinbase && minimum_depth < COINBASE_MATURITY {
8442+ COINBASE_MATURITY
8443+ } else {
8444+ minimum_depth
8445+ }
8446+ };
8447+
8448+ if funding.funding_tx_confirmation_height == 0 {
8449+ return false;
8450+ }
8451+
8452+ let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
8453+ if funding_tx_confirmations < minimum_depth as i64 {
8454+ return false;
8455+ }
8456+
8457+ return true;
8458+ }
8459+
84608460 /// When a transaction is confirmed, we check whether it is or spends the funding transaction
84618461 /// In the first case, we store the confirmation height and calculating the short channel id.
84628462 /// In the second, we simply return an Err indicating we need to be force-closed now.
0 commit comments