Saturday, October 12, 2024

bitcoin core – How does a miner create a number of outputs in a coinbase transaction?

Bitcoin core hard-codes the coinbase transaction to 1 output coinbaseTx.vout.resize(1) as outlined in src/node/miner.cpp

     // Create coinbase transaction.
    CMutableTransaction coinbaseTx;
    coinbaseTx.vin.resize(1);
    coinbaseTx.vin[0].prevout.SetNull();

****************************************************
//Referring to the road of code under 
    coinbaseTx.vout.resize(1);

*****************************************************
    coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
    coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
    coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
    pblock->vtx[0] = MakeTransactionRef(std::transfer(coinbaseTx));
    pblocktemplate->vchCoinbaseCommitment = m_chainstate.m_chainman.GenerateCoinbaseCommitment(*pblock, pindexPrev);
    pblocktemplate->vTxFees[0] = -nFees;

    LogPrintf("CreateNewBlock(): block weight: %u txs: %u charges: %ld sigops %dn", GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);

Nevertheless, not too long ago in block 860062 the Mining Pool paid a number of distant miners instantly from the coin-base transaction.
https://mempool.area/tx/aff7c9b18666c0a51c66013642e24bfcb8b721a674e0f4ce3afa3004b55b0156

How does the miner create a coinbase transaction that overrides the default values stipulated within the above code-snippet from Bitcoin core?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles