In the original source code there were little restrictions on what could be in the coinbase data of the coinbase transaction. I think the only restriction was that the coinbase data should be between 2 and 100 bytes. However, the lack of restriction on the coinbase data put itself to a vulnerability where a miners could create a coinbase transaction identical to previous one and mine it in a block at a height higher than where the "original" coinbase transaction. This led to the invalidation of the previous transaction.
This was fixed later when couple of blocks were mined with identical coinbase data. As per BIP-34, version-2 blocks must contain the block height index as a script push operation in the beginning of the coinbase field. For example, in your coinbase transaction this data is represented by the bytes 0x03400d03
. The first byte 0x03
indicates the script should push the next 3 bytes. The next three bytes 0x400d03
represent the block height 200,000 in little endian.
The rest of the coinbase data is free for the miners to use as per their will. This is mostly used as a space for extra-nonce. In the early days of Bitcoin, a miner could find a block by iterating through the nonce until the resulting hash was below the target. As difficulty increased, miners often cycled through all 4 billion values of the nonce (232) without finding a block header solution. However, this was easily resolved by updating the block timestamp to account for the elapsed time. Because the timestamp is part of the header, the change would allow miners to iterate through the values of the nonce again with different results.
Once mining hardware became really efficient, however, this approach became increasingly difficult because the nonce values were exhausted in less than a second. Hence, the mining software needed more space for nonce values in order to find valid blocks. The timestamp could be stretched a bit, but moving it too far into the future would cause the block to become invalid. The solution was to use the coinbase transaction as a source of extra nonce values. Because the coinbase script can store between 2 and 100 bytes of data (~first 4 bytes reserved for block identification), miners started using that 96 byte space as extra nonce, allowing them to explore a much larger range of block header values to find valid blocks.
The mining pools also use the coinbase data as an identification who mined the block. For example if you look at block 594,041, you will see the coinbase data contain the bytes 0x4d696e656420627920416e74506f6f6c
. It represents "'Mined by AntPool" in ASCII. (Unfortunately the block you mentioned did not have any identification). However, this data cannot be relied, as even I can mine a block tomorrow with that data claiming it to be mined by Antpool.