Fix bug in difficulty calculation
@@ -67,10 +67,10 @@ class BlockHeader:
raise ValueError("Invalid block previous hash length")
if len(self.merkleroot) != 64:
raise ValueError("Invalid block merkle root length")
- target = int.from_bytes(self.bits[-3:], "little")
+ target = int.from_bytes(self.bits[-3:], "big")
exp: int = pow(256, (self.bits[0] - 3))
target *= exp
- if int.from_bytes(bytes.fromhex(self.hash), "big") > target:
+ if int(self.hash, 16) > target:
raise ValueError("Invalid nonce")
