Merkle root with one transaction

Bitcoin Asked by Hamita on December 28, 2021

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

After creating the coinbase transaction, do I need to convert it to little endian, hash it twice and then put it in the blockheader as it is, or do I have to it 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

2 Answers

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

Answered by Hamita on December 28, 2021

Whenever data is serialized to bytes in Bitcoin, the bytes are represented in little endian. (Data that is already in bytes does not need to be serialized or otherwise converted.)

When there is only a single element in the merkle tree, the root of the tree is the hash of that element. Therefore, you would only need to serialize the coinbase transaction and hash the bytes resulting from the serialization. The resulting hash is the coinbase's txid as well as the merkle root.

Answered by Murch on December 28, 2021

Add your own answers!

Related Questions

Bitcoind daemon: error connecting to the server?

1  Asked on October 24, 2021 by komputer


Cannot open dump wallet file (code-8)

1  Asked on October 24, 2021 by requim


Opening a wallet with bitcoind

2  Asked on October 24, 2021 by steve-merriman


How can I download a single Bitcoin block?

1  Asked on October 24, 2021 by seonguk-park


What are “leaf versions” in Taproot?

2  Asked on October 24, 2021 by bertram-lund


Cannot start C-lightning after reboot

1  Asked on October 24, 2021 by jodobear


ElectrumX server as a Tor hidden service

1  Asked on October 24, 2021 by taghi


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir