matteocrippa / matteocrippa/leafminer
Merkle root not reversed?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 158
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
When looking at the bictcoin wiki: https://en.bitcoin.it/wiki/Block_hashing_algorithm
It is clearly mentioned that merkle root hash should be reversed.
``` $prevBlockHash = SwapOrder('00000000000008a3a41b85b8b29ad444def299fee21793cd8b9e567eab02cd81');
$rootHash = SwapOrder('2b12fcf1b09288fcaff797d71e950e71ae42b91e8bdb2304758dfcffc2b620e3');
```
When looking at the leaf code, it isn't done :
https://github.com/matteocrippa/leafminer/blob/main/src/model/job.cpp#L30
``` std::string merkle_root;
calculateMerkleRoot(coinbase_hash, notification.merkle_branch, merkle_root);
```
The Previous hash is correctly reversed.
```
block.version = strtoul(version, nullptr, 16);
hexStringToByteArray(prevhash, block.previous_block);
reverseBytesAndFlip(block.previous_block, 32);
```
Why is that?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Bitcoin block hashing algorithm linked in the issue, then inspect src/model/job.cpp at line 30 and trace calculateMerkleRoot. Compare its merkle-root byte handling with the reverseBytesAndFlip treatment of block.previous_block. Done means the byte order is verified against the referenced algorithm and the issue's question is resolved in the relevant code or documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- blockchain, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100