0

From my knowledge a header hash will be calculated like this:

  1. serialize all header fields, including "the nonce"
  2. hash the serialized header once
  3. hash the hashed serialized header again
  4. check if the result is below the target
  5. if no: choose a different nonce and start over

I'm referring to this site that allows you to enter some header data and calculate the header hash:

https://learnmeabitcoin.com/tools/hashblockheader/?version=536870912&hashPrevBlock=00000000000000000001eaef94e697cae4216042819d6e2c6ec1c959f8112b38&hashMerkleRoot=eb9439ab4f13d3bd448b792d30a97e4632e567d5e6e40c2d5c9a72f27edbddbd&time=1644443882&bits=170a8bb4&nonce=3156027&submit=true

The site already calculates the serialized header that I have to use for the hashing process:

00000020382b11f859c9c16e2c6e9d81426021e4ca97e694efea01000000000000000000bddddb7ef2729a5c2d0ce4e6d567e532467ea9302d798b44bdd3134fab3994ebea380462b48b0a173b283000 

So running this serialized header through SHA256 for two times gives me this hash after the first iteration:

969d0e7028705a4ca408430f5d2bcb05acbcd6c3350f43a838714a2ba5db94f0

And hashing this again would return:

9fe2e96559673ba8e038452cc161e2da87636567d95ef7ae6be800770a5cbf9f

But this is not the actual hash for this block header. Apparently, because starting with a 9 seems not be very difficult. That is the correct header:

000000000000000000055730c92292ebd5c5851e7d24ab3ba2efc1cea0b5fe81

So I'm wondering, what additional step I'm missing here?

Thank you

1 Answer 1

4

The problem is that you are hashing the header as a string, not as the bytes that the hex represents. If you hash it as bytes, you will get the expected hash. Both the header, and the first hash, must be treated as bytes, not a hex string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.