@@ -479,6 +479,9 @@ pub(crate) const MIN_AFFORDABLE_HTLC_COUNT: usize = 4;
479
479
/// * `EXPIRE_PREV_CONFIG_TICKS` = convergence_delay / tick_interval
480
480
pub ( crate ) const EXPIRE_PREV_CONFIG_TICKS : usize = 5 ;
481
481
482
+ /// Number of blocks needed for an output from a coinbase transaction to be spendable.
483
+ pub ( crate ) const COINBASE_MATURITY : u32 = 100 ;
484
+
482
485
struct PendingChannelMonitorUpdate {
483
486
update : ChannelMonitorUpdate ,
484
487
/// In some cases we need to delay letting the [`ChannelMonitorUpdate`] go until after an
@@ -5235,6 +5238,15 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5235
5238
}
5236
5239
}
5237
5240
}
5241
+
5242
+ // if this is a coinbase transaction and not a 0-conf channel
5243
+ // we should update our min_depth to 100 to handle coinbase maturity
5244
+ if tx. is_coin_base ( ) &&
5245
+ self . minimum_depth . unwrap_or ( 0 ) > 0 &&
5246
+ self . minimum_depth . unwrap_or ( 0 ) < COINBASE_MATURITY {
5247
+ self . minimum_depth = Some ( COINBASE_MATURITY ) ;
5248
+ }
5249
+
5238
5250
// If we allow 1-conf funding, we may need to check for channel_ready here and
5239
5251
// send it immediately instead of waiting for a best_block_updated call (which
5240
5252
// may have already happened for this block).
@@ -5547,6 +5559,15 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5547
5559
5548
5560
self . channel_state = ChannelState :: FundingCreated as u32 ;
5549
5561
self . channel_id = funding_txo. to_channel_id ( ) ;
5562
+
5563
+ // If the funding transaction is a coinbase transaction, we need to set the minimum depth to 100
5564
+ // We can skip this if it is a zero-conf channel.
5565
+ if funding_transaction. is_coin_base ( ) &&
5566
+ self . minimum_depth . unwrap_or ( 0 ) > 0 &&
5567
+ self . minimum_depth . unwrap_or ( 0 ) < COINBASE_MATURITY {
5568
+ self . minimum_depth = Some ( COINBASE_MATURITY ) ;
5569
+ }
5570
+
5550
5571
self . funding_transaction = Some ( funding_transaction) ;
5551
5572
5552
5573
Ok ( msgs:: FundingCreated {
0 commit comments