For example, genesis-hash is the (in pseudo-code):
sha256(sha256(version+previousblockheader+hash+merkleroothash+time+nBits+nonce))
than convert hash from little endian to big endian - voila!
It's very easy to understand. Thank you - you explained.
And how about Merkle root hash?
SHA256d(coinbaseTransaction)
voila!
It's very easy to understand.
achow101 already explained:
1. How can I get a Merkle root hash?
By constructing the coinbase transaction of the genesis block and hashing it.
How can I get coinbase for genesis-block?
To avoid confusion, please be aware that many people use the term "generation transaction" instead of "coinbase transaction". In Bitcoin, these two phrases mean the exact same thing. So, if you read anything about a bitcoin generation transaction, then it is talking about the same thing as a bitcoin coinbase transaction.
The Bitcoin genesis block coinbase transaction is as follows:
0x01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000
Look closely and you'll see that includes the following values:
5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73
If you convert those hex values to ASCII characters, you'll get the following:
The Times 03/Jan/2009 Chancellor on brink of second bailout for banks
To better understand the contents of a bitcoin transaction, you can read this:
https://en.bitcoin.it/wiki/TransactionI'll start at the beginning and break that transaction into some of the larger components in order for you to follow along (I'll leave it to you to break them down to their sub-components if you want to:
- 01000000 (4 byte version number in little-endian byte order)
- 01 (1 byte indication of the number of inputs in the transaction)
- 0000000000000000000000000000000000000000000000000000000000000000 (32 byte hash of input transaction, since coinbase transactions don't have an input, this is always 32 bytes of 0)
- ffffffff (4 byte index of the specific output being spent from the input transaction, since coinbase transactions don't have an input this value is being used as a place-holder)
- 4d (1 byte indication of the length of the input script, hex 4d is decimal 77 so the input script will be 77 bytes long)
- 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f7 2206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73 (77 byte input script)
- ffffffff (4 byte sequence number)
- 01 (1 byte indication of the number of outputs in the transaction)
- 00f2052a01000000 (8 byte output value in little-endian byte order, little-endian hex 00f2052a01000000 is 5000000000 so this is a 50 BTC output)
- 43 (1 byte indication of the length of the output script, hex 43 is decimal 65 so the output script will be 65 bytes long)
- 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4ce f38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac (65 byte output script)
- 00000000 (4 byte lock time)