user11187: I'm trying to understand the format of the coinbase transaction. I've read that it is arbitrary and not specified. I'm wondering because I need to generate mining work and create an internal pool. As I've found out, you can change the ntime, nonce and extranonce fields. The last one should be suited in the coinbase parameter, right? So, can anyone help me analyze the content of the coinbase transaction and how am I supposed to build one, so all miners in my pool could have different headers for hashing? A step-by-step guide on an existing block would be much appreciated, links and other stuff too. 

user10411: Look at block #280963. Look at coinbase transaction d1c6b8...fd08. You can see CoinBase data:
038349040d00456c69676975730052d8f72ffabe6d6dd991088decd13e658bbecc0b2b4c87306f637828917838c02a5d95d0e1bdff9b0400000000000000002f73733331312f00906b570400000000e4050000

This is a script. Look at wiki for details. In coinbase transaction this script can contain any data. If you change this data, merkle root will change as well, and diffirent miners can start changing nonce/timestamp for merlke root, that you provides for them. Look at wiki for more information about merkle tree.
Coinbase transaction contains single input. This is input is not used, and it contains 32 bytes zeros as previous tx. Look at wiki for more information about what data transaction contains. I provide as example of decoding raw coinbase transaction.
> getrawtransaction d1c6b8140246950475735394b0ac68f9ada60d313d2b5308afbc569c84f7fd08
< 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff53038349040d00456c69676975730052d8f72ffabe6d6dd991088decd13e658bbecc0b2b4c87306f637828917838c02a5d95d0e1bdff9b0400000000000000002f73733331312f00906b570400000000e4050000ffffffff01bf208795000000001976a9145399c3093d31e4b0af4be1215d59b857b861ad5d88ac00000000

01000000 - version
01 - input count
0000000000000000000000000000000000000000000000000000000000000000 - prev tx
ffffffff - prev out n
53 - length of coinbase script
038349040d00456c69676975730052d8f72ffabe6d6dd991088decd13e658bbecc0b2b4c87306f637828917838c02a5d95d0e1bdff9b0400000000000000002f73733331312f00906b570400000000e4050000 - coinbase script
ffffffff - sequence
01 - output count
bf20879500000000 - 2508660927, satoshi count, or 25.08660927 BTC
19 - script length
76a9145399c3093d31e4b0af4be1215d59b857b861ad5d88ac - script
00000000 - locktime


user208: A coinbase transaction follows the same format as a normal transaction, except:

It has exactly one txin
This txin's prevout hash is 0000...0000.
This txin's prevout index is 0xFFFFFFFF
The txin's prevout script is an arbitrary byte array (it doesn't have to be a valid script, though this is commonly done anyway) of 2 to 100 bytes. It has to start with a correct push of the block height (see BIP34).
The sum of the txout's values cannot exceed the subsidy (25 BTC for now, halves every 210000 blocks) plus the fees of the non-coinbase transactions in the same block.

About the scriptSig being an arbitrary byte array, there is one caveat: the checksig operations in it are counted towards the block sigop limit (20000), so you probably don't want to accidentally trigger this. Making it a list of just push operations (including of the extranonce) avoids that.

11187: <p>I'm trying to understand the format of the coinbase transaction. I've read that it is arbitrary and not specified. I'm wondering because I need to generate mining work and create an internal pool. As I've found out, you can change the <code>ntime</code>, <code>nonce</code> and <code>extranonce</code> fields. The last one should be suited in the coinbase parameter, right? So, can anyone help me analyze the content of the coinbase transaction and how am I supposed to build one, so all miners in my pool could have different headers for hashing? A step-by-step guide on an existing block would be much appreciated, links and other stuff too. </p>
 10411: <p>Look at block <a href="https://blockchain.info/block-index/461072/0000000000000002001dfbeaf7a89087854de6aa3928bbcbbd28a60d286a85c1">#280963</a>. Look at coinbase transaction <a href="https://blockchain.info/tx/d1c6b8140246950475735394b0ac68f9ada60d313d2b5308afbc569c84f7fd08">d1c6b8...fd08</a>. You can see CoinBase data:</p>

<pre><code>038349040d00456c69676975730052d8f72ffabe6d6dd991088decd13e658bbecc0b2b4c87306f637828917838c02a5d95d0e1bdff9b0400000000000000002f73733331312f00906b570400000000e4050000
</code></pre>

<p>This is a script. Look at <a href="https://en.bitcoin.it/wiki/Script">wiki</a> for details. In coinbase transaction this script can contain any data. If you change this data, merkle root will change as well, and diffirent miners can start changing nonce/timestamp for merlke root, that you provides for them. Look at <a href="https://en.bitcoin.it/wiki/Protocol_specification#Merkle_Trees">wiki</a> for more information about merkle tree.</p>

<p>Coinbase transaction contains single input. This is input is not used, and it contains 32 bytes zeros as previous tx. Look at <a href="https://en.bitcoin.it/wiki/Transactions">wiki</a> for more information about what data transaction contains. I provide as example of decoding raw coinbase transaction.</p>

<pre><code>&gt; getrawtransaction d1c6b8140246950475735394b0ac68f9ada60d313d2b5308afbc569c84f7fd08
&lt; 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff53038349040d00456c69676975730052d8f72ffabe6d6dd991088decd13e658bbecc0b2b4c87306f637828917838c02a5d95d0e1bdff9b0400000000000000002f73733331312f00906b570400000000e4050000ffffffff01bf208795000000001976a9145399c3093d31e4b0af4be1215d59b857b861ad5d88ac00000000

01000000 - version
01 - input count
0000000000000000000000000000000000000000000000000000000000000000 - prev tx
ffffffff - prev out n
53 - length of coinbase script
038349040d00456c69676975730052d8f72ffabe6d6dd991088decd13e658bbecc0b2b4c87306f637828917838c02a5d95d0e1bdff9b0400000000000000002f73733331312f00906b570400000000e4050000 - coinbase script
ffffffff - sequence
01 - output count
bf20879500000000 - 2508660927, satoshi count, or 25.08660927 BTC
19 - script length
76a9145399c3093d31e4b0af4be1215d59b857b861ad5d88ac - script
00000000 - locktime
</code></pre>
 208: <p>A coinbase transaction follows the same format as a normal transaction, except:</p>

<ul>
<li>It has exactly one txin</li>
<li>This txin's prevout hash is 0000...0000.</li>
<li>This txin's prevout index is 0xFFFFFFFF</li>
<li>The txin's prevout script is an arbitrary byte array (it doesn't have to be a valid script, though this is commonly done anyway) of 2 to 100 bytes. It has to start with a correct push of the block height (see BIP34).</li>
<li>The sum of the txout's values cannot exceed the subsidy (25 BTC for now, halves every 210000 blocks) plus the fees of the non-coinbase transactions in the same block.</li>
</ul>

<p>About the scriptSig being an arbitrary byte array, there is one caveat: the checksig operations in it are counted towards the block sigop limit (20000), so you probably don't want to accidentally trigger this. Making it a list of just push operations (including of the extranonce) avoids that.</p>
