Converted to hex it is: 4a7a43 ---> 6 Bytes instead of 8
Something's gone wobbly here.
The nonce of 70755497 is stored in the block header as "a9a43704" (4 bytes). This is precisely the 4-byte
My quick Python 3 check:
>>> (70755497).to_bytes(4, byteorder='little')
b'\xa9\xa47\x04'
>>> ''.join(format(byte, '02x') for byte in _)
'a9a43704'
If've tried to put "00" bevor and behind the digits, but that doesn't solve the problem.
In this
import hashlib
def sha256(message):
return hashlib.sha256(message).digest()
version = '03000000'
previous_hash = 'e63b16136d61d94bcda2b6609fad58c217dd9a73be7310050000000000000000'
merkle_root = '213f7741f14eb9b972b44402647b20f1e2705c73416dfb35d5f0b6fca86eb8e9'
time = '098d0656'
bits = 'ba871218'
nonce = 'a9a43704'
header = ''.join([version, previous_hash, merkle_root, time, bits, nonce])
hash_bytes = sha256(sha256(bytes.fromhex(header)))
print(''.join(format(byte, '02x') for byte in reversed(hash_bytes)))
Edit: Corrected big-endian to little-endian throughout. Cheers Danny.