Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | def create_coinbase(height, pubkey=None): | ||||
coinbaseoutput.nValue = 50 * COIN | coinbaseoutput.nValue = 50 * COIN | ||||
halvings = int(height / 150) # regtest | halvings = int(height / 150) # regtest | ||||
coinbaseoutput.nValue >>= halvings | coinbaseoutput.nValue >>= halvings | ||||
if (pubkey != None): | if (pubkey != None): | ||||
coinbaseoutput.scriptPubKey = CScript([pubkey, OP_CHECKSIG]) | coinbaseoutput.scriptPubKey = CScript([pubkey, OP_CHECKSIG]) | ||||
else: | else: | ||||
coinbaseoutput.scriptPubKey = CScript([OP_TRUE]) | coinbaseoutput.scriptPubKey = CScript([OP_TRUE]) | ||||
coinbase.vout = [coinbaseoutput] | coinbase.vout = [coinbaseoutput] | ||||
# Make sure the coinbase is at least 100 bytes | |||||
coinbase_size = len(coinbase.serialize()) | |||||
if coinbase_size < 100: | |||||
coinbase.vin[0].scriptSig += b'x' * (100 - coinbase_size) | |||||
coinbase.calc_sha256() | coinbase.calc_sha256() | ||||
return coinbase | return coinbase | ||||
# Create a transaction. | # Create a transaction. | ||||
# If the scriptPubKey is not specified, make it anyone-can-spend. | # If the scriptPubKey is not specified, make it anyone-can-spend. | ||||
def create_transaction(prevtx, n, sig, value, scriptPubKey=CScript()): | def create_transaction(prevtx, n, sig, value, scriptPubKey=CScript()): | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |