I've read that it's some variation of: version, previous block hash, merkle root, time, bits, and nonce, but I'm not certain on where to get this data and how it should be formatted. I'd like to know the exact string I can put into something like this and exactly where I can find it. I've followed this video and downloaded his spreadsheet but am uncertain on which part I can copy into the hash function to get the same output as the spreadsheet. Also wondering about how to convert time to the right format. Thanks in advance.
1 Answer
I've read that it's some variation of: version, previous block hash, merkle root, time, bits, and nonce
This is exactly right.
Manually verify block hash
(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 terminal command (unix):
$ 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!
I'd like to know the exact string I can put into something like this and exactly where I can find it
This likely will not work because it looks like it's expecting a string and it will be strange to try and convert the bytes in the block header to ASCII characters.
Note: You will need to install openssl for terminal. Also, the xxd
command will convert the hex string to bytes so the hash is not done on the ASCII bytes.