I am currently trying to validate a blocks hash against its target in python3:
This is a block in the Blockcypher testnet, and I am using this formula from the Bitcoin Wiki.
block_hash = '000055f67563d1c2cb141d06d52d2fca63ef457c553519aeb635a2643a9af0b1'
bits = '520159231'
target = hex(int(bits) * (2**(8 * (0x1b - 3))))
hash_ = hex(int(block_hash, 16))
print(target, hash_)
>>> 0x1f00ffff000000000000000000000000000000000000000000000000 0x55f67563d1c2cb141d06d52d2fca63ef457c553519aeb635a2643a9af0b1
if not target >= hash_:
print('False)
else:
print('True')
>>> False
Point is, that target is less than blockhash. But this should not be the case. Can anyone help me?
Thank You for Your time.