Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
def create_coinbase(height, pubkey=None): | def create_coinbase(height, pubkey=None): | ||||
coinbase = CTransaction() | coinbase = CTransaction() | ||||
coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), | coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), | ||||
ser_string(serialize_script_num(height)), 0xffffffff)) | ser_string(serialize_script_num(height)), 0xffffffff)) | ||||
coinbaseoutput = CTxOut() | coinbaseoutput = CTxOut() | ||||
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 is not 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 | # Make sure the coinbase is at least 100 bytes | ||||
pad_tx(coinbase) | pad_tx(coinbase) | ||||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |