<p>Bitcoin Core provides two distinct mining interfaces:</p>
<ul>
<li>A production mining interface through the <code>getblocktemplate</code> RPC, which provides information about the block header and transactions to include, but lets the miner/pool construct the block and coinbase transaction themselves, plus let the miner do their own nonce grinding (the vast majority of the computational work) using specialized hardware/software.</li>
<li>A testing interface through RPCs like <code>generatetoaddress</code>, which construct a full block, grind the nonce using unoptimized CPU code, and submit a block to the network. It's only feasible for test networks where the difficulty is low.</li>
</ul>
<p>The code you are citing is technically invoked in both interfaces, but for the production one, the resulting coinbase transaction is a dummy that gets ignored; for real-world mining, the coinbase transaction construction is done by the miner's/pool's software or hardware.</p>

CC BY-SA 4.0
2024-09-08T17:12:47.787Z
Thank you so much for the response. That clears the doubt I had.
Faisal Qureshi
CC BY-SA 4.0
2024-09-08T16:43:03.853Z
2024-09-08T16:59:51.427Z
2024-09-08T16:59:51.427Z
Pieter Wuille
<p>Bitcoin Core hard-codes the coinbase transaction to one output <code>coinbaseTx.vout.resize(1)</code> as defined in <code>src/node/miner.cpp</code></p>
<pre><code>     // Create coinbase transaction.
    CMutableTransaction coinbaseTx;
    coinbaseTx.vin.resize(1);
    coinbaseTx.vin[0].prevout.SetNull();

****************************************************
//Referring to the line of code below 
    coinbaseTx.vout.resize(1);

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

    LogPrintf(&quot;CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops %d\n&quot;, GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);
</code></pre>
<p>However, recently in block 860062 the mining pool paid multiple remote miners directly from the <a href="https://mempool.space/tx/aff7c9b18666c0a51c66013642e24bfcb8b721a674e0f4ce3afa3004b55b0156" rel="nofollow noreferrer">coinbase transaction</a>.</p>
<p>How does the miner create a coinbase transaction that overrides the default values stipulated in the above code-snippet from Bitcoin Core?</p>

<bitcoin-core><mining-pools><bitcoin-core-development><mining-reward><coinbase-transaction>
How does a miner create multiple outputs in a coinbase transaction?
Faisal Qureshi
# How does a miner create multiple outputs in a coinbase transaction?

(Asked by: username_0 on 2024-09-08)

Bitcoin Core hard-codes the coinbase transaction to one output coinbaseTx.vout.resize(1) as defined in src/node/miner.cpp
     // Create coinbase transaction.
    CMutableTransaction coinbaseTx;
    coinbaseTx.vin.resize(1);
    coinbaseTx.vin[0].prevout.SetNull();

****************************************************
//Referring to the line of code below 
    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::move(coinbaseTx));
    pblocktemplate->vchCoinbaseCommitment = m_chainstate.m_chainman.GenerateCoinbaseCommitment(*pblock, pindexPrev);
    pblocktemplate->vTxFees[0] = -nFees;

    LogPrintf("CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops %d\n", GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);

However, recently in block 860062 the mining pool paid multiple remote miners directly from the coinbase transaction.
How does the miner create a coinbase transaction that overrides the default values stipulated in the above code-snippet from Bitcoin Core?

**Tags:** bitcoin-core, mining-pools, bitcoin-core-development, mining-reward, coinbase-transaction


---

## 1 answers

### Answer by username_1 on 2024-09-08. Score: 7

Bitcoin Core provides two distinct mining interfaces:

* A production mining interface through the `getblocktemplate` RPC, which provides information about the block header and transactions to include, but lets the miner/pool construct the block and coinbase transaction themselves, plus let the miner do their own nonce grinding (the vast majority of the computational work) using specialized hardware/software.
* A testing interface through RPCs like `generatetoaddress`, which construct a full block, grind the nonce using unoptimized CPU code, and submit a block to the network. It's only feasible for test networks where the difficulty is low.

The code you are citing is technically invoked in both interfaces, but for the production one, the resulting coinbase transaction is a dummy that gets ignored; for real-world mining, the coinbase transaction construction is done by the miner's/pool's software or hardware.

> **Comments:**
> **username_0**: Thank you so much for the response. That clears the doubt I had.  

---

