How To Calculate Merkle Root?

0

I found this example:


Current merkle hash list: 32650049a0418e4380db0af81788635d8b65424d397170b8499cdc28c4d27006 30861db96905c8dc8b99398ca1cd5bd5b84ac3264a4e1b3e65afa1bcee7540c4

Current merkle hash list: d47780c084bad3830bcdaf6eace035e4c6cbf646d103795d22104fb105014ba3


I have tried to calculate the hash using PHP:

$tx1="32650049a0418e4380db0af81788635d8b65424d397170b8499cdc28c4d27006";
$tx2="30861db96905c8dc8b99398ca1cd5bd5b84ac3264a4e1b3e65afa1bcee7540c4";
$v=hash('sha256', hash('sha256',$tx1.$tx2) );

But I got:
2b5f377b4adab64f489a2f73605ffb448b8add5b708d218729f9dfc58f1f5fe2

What is wrong?

Sh Sh

Posted 2017-10-16T09:10:02.577

Reputation: 366

2you should hash the binary data, not the human-readable hexadecimal representationamaclin 2017-10-16T09:32:35.533

@amaclin Sounds like that should be an answer, not just a commentPieter Wuille 2017-10-17T17:38:24.387

No answers