@@ -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
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
483
486
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
484
487
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -5142,6 +5145,15 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5142
5145
}
5143
5146
}
5144
5147
}
5148
+
5149
+ // if this is a coinbase transaction and not a 0-conf channel
5150
+ // we should update our min_depth to 100 to handle coinbase maturity
5151
+ if tx. is_coin_base ( ) &&
5152
+ self . minimum_depth . unwrap_or ( 0 ) > 0 &&
5153
+ self . minimum_depth . unwrap_or ( 0 ) < COINBASE_MATURITY {
5154
+ self . minimum_depth = Some ( COINBASE_MATURITY ) ;
5155
+ }
5156
+
5145
5157
// If we allow 1-conf funding, we may need to check for channel_ready here and
5146
5158
// send it immediately instead of waiting for a best_block_updated call (which
5147
5159
// may have already happened for this block).
@@ -5454,6 +5466,15 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5454
5466
5455
5467
self . channel_state = ChannelState :: FundingCreated as u32 ;
5456
5468
self . channel_id = funding_txo. to_channel_id ( ) ;
5469
+
5470
+ // If the funding transaction is a coinbase transaction, we need to set the minimum depth to 100
5471
+ // We can skip this if it is a zero-conf channel.
5472
+ if funding_transaction. is_coin_base ( ) &&
5473
+ self . minimum_depth . unwrap_or ( 0 ) > 0 &&
5474
+ self . minimum_depth . unwrap_or ( 0 ) < COINBASE_MATURITY {
5475
+ self . minimum_depth = Some ( COINBASE_MATURITY ) ;
5476
+ }
5477
+
5457
5478
self . funding_transaction = Some ( funding_transaction) ;
5458
5479
5459
5480
Ok ( msgs:: FundingCreated {
0 commit comments