Skip to content

Instantly share code, notes, and snippets.

@humbdrag
Created January 27, 2022 20:55
Show Gist options
  • Save humbdrag/109dc0c8e7bb221860010634e279bf4b to your computer and use it in GitHub Desktop.
Save humbdrag/109dc0c8e7bb221860010634e279bf4b to your computer and use it in GitHub Desktop.
Calculate block header for pyminer
def calc_block_header(block: Dict) -> bytes:
return (
struct.pack("<L", block["version"])
+ bytes.fromhex(block["previousblockhash"])[::-1]
+ bytes.fromhex(block["merkleroot"])[::-1]
+ struct.pack("<L", block["curtime"])
+ bytes.fromhex(block["bits"])[::-1]
+ struct.pack("<L", block["nonce"])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment