How to manually verify the hash of a Bitcoin block (command line)

Jordan Baczuk
1 min readMay 31, 2018

Because, why not, right?

Steps

(thanks to @exmachinalibertas) on this reddit comment

  • Grab a block (eg. block 3): Block 3 in json or Block 3 in hex
  • Concatenate (in this order, little endian, hex format) the version, previous block hash, merkle root, unix epoch time, difficulty target (bits), and nonce. You’ll see you can copy the first 160 characters from the Block 3 in hex link.
01000000bddd99ccfda39da1b108ce1a5d70038d0a967bacb68b6b63065f626a0000000044f672226090d85db9a9f2fbfe5f0f9609b387af7be5b7fbb7a1767c831c9e995dbe6649ffff001d05e0ed6d
  • Run the command:
echo 01000000bddd99ccfda39da1b108ce1a5d70038d0a967bacb68b6b63065f626a0000000044f672226090d85db9a9f2fbfe5f0f9609b387af7be5b7fbb7a1767c831c9e995dbe6649ffff001d05e0ed6d | xxd -r -p | openssl sha -sha256 | xxd -r -p | openssl sha -sha256
  • Reverse the output from
4944469562ae1c2c74d9a535e00b6f3e40ffbad4f2fda3895501b58200000000

to

0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449

And there’s the block hash!

--

--