Merkle root with one transaction


I am trying to build a merkle root which contains only the coinbase transaction from bitcoind

After creating the coinbase transaction i need to convert it to little endian, hash it twice and then put it in the blockheader as it is, or i must reconvert it again before i put it in the blockheader

I mean:

step 1: convert coinbase transaction to little endian

step 2 : double SHA256

step 3 : reconvert to little endian or let it as it's?

step 4 : put it on the blockheader

I am a little confused

Thank you for help


Posted 2020-07-24T12:49:14.550

Reputation: 79



I think you may be missing that when a node in the Merkle tree doesn't have a hashing partner it is concatenated with itself before hashing. To calculate the Merkle root of a transaction tree with a single transaction txid0, you would need to hash:

Merkle root = sha256d(txid0 + txid0)

I'm not sure about the endianess conversions.


Posted 2020-07-24T12:49:14.550

Reputation: 51 063

ah, thank you, i thought we do this when it's an odd number of transactions, and according to the documentation, it says when it contains only the coinbase transaction, the merkle root will be the same – Hamita – 2020-07-24T18:14:27.590


I put the answer for my question here, if someone else need it, the right answer is: Convert before hashing and after hashing


Posted 2020-07-24T12:49:14.550

Reputation: 79