I would like to hash a block header using terminal commands and look at all the pretty leading 0s, but I can't figure out how to do this correctly using block header data from bitcoin-cli.
Here is what I tried:
# get the block header of a recent block and write it to # get the block header of a recent block and write it to blockheader.txt
$ bitcoin-cli getblockheader 0000000000000000000493a92e28a9f9402cef0ff3f953aeca17b506700dfaf9 false > blockheader.txt
# hash it twice
$ sha256sum blockheader.txt > hash1.txt
$ sha256sum hash1.txt
abcaf9cb4c4ea594cdaf330f143f8d5e31fd0539540906149ab0e3d706b7d053 hash1.txt
As you can see, the output does not match the blockhash input in the first command. What am I doing wrong?
blockheader.txt
has a linebreak at the end, and whether the serialized data actually matches the required input formatting? Might be something like the version needing to be put in low-endian: https://bitcoin.stackexchange.com/a/67792/5406 – Murch Jan 09 '23 at 18:06