Last active
January 27, 2022 20:59
-
-
Save humbdrag/ec6de05656ae13ace7f7cc68db4ca182 to your computer and use it in GitHub Desktop.
Insert Coinbase transaction pyminer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from essential_generators import DocumentGenerator | |
import hashlib | |
def sha256_double_hash(target: str) -> str: | |
return hashlib.sha256( | |
hashlib.sha256(target).digest() | |
).digest()[::-1] | |
coinbase = {} | |
coinbase_text: str = DocumentGenerator().sentence().encode().hex() | |
coinbase['data'] = create_coinbase( | |
coinbase_value=block_template['coinbasevalue'], | |
coinbase_text=coinbase_text, | |
block_height=block_template['height'], | |
wallet_address=wallet_address, | |
) | |
coinbase['hash'] = sha256_double_hash(bytes.fromhex(coinbase['data'])).hex() | |
block_template['transactions'].insert(0, coinbase) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment