// Assuming tx is a pointer to a CTransaction object if (tx->IsCoinBase()) { // This is a coinbase transaction } else { // This is not a coinbase transaction }
// Assuming block is a pointer to a CBlock object for (const auto& tx : block->vtx) { if (tx->IsCoinBase()) { // This is a coinbase transaction, skip it continue; } // Process the transaction normally }In both examples, we use the IsCoinBase method to check if a transaction is a coinbase transaction. If it is, we can take special actions, such as skipping it when processing a block. This method is an essential tool for any Bitcoin-related software to correctly handle coinbase transactions.