Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | def create_coinbase(height, pubkey=None): | ||||
# Make sure the coinbase is at least 100 bytes | # Make sure the coinbase is at least 100 bytes | ||||
pad_tx(coinbase) | pad_tx(coinbase) | ||||
coinbase.calc_sha256() | coinbase.calc_sha256() | ||||
return coinbase | return coinbase | ||||
def create_tx_with_script(prevtx, n, script_sig=b"", amount=1, script_pub_key=CScript()): | def create_tx_with_script(prevtx, n, script_sig=b"", | ||||
amount=1, script_pub_key=CScript()): | |||||
"""Return one-input, one-output transaction object | """Return one-input, one-output transaction object | ||||
spending the prevtx's n-th output with the given amount. | spending the prevtx's n-th output with the given amount. | ||||
Can optionally pass scriptPubKey and scriptSig, default is anyone-can-spend output. | Can optionally pass scriptPubKey and scriptSig, default is anyone-can-spend output. | ||||
""" | """ | ||||
tx = CTransaction() | tx = CTransaction() | ||||
assert(n < len(prevtx.vout)) | assert(n < len(prevtx.vout)) | ||||
tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), script_sig, 0xffffffff)) | tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), script_sig, 0xffffffff)) | ||||
Show All 35 Lines | def get_legacy_sigopcount_block(block, fAccurate=True): | ||||
return count | return count | ||||
def get_legacy_sigopcount_tx(tx, fAccurate=True): | def get_legacy_sigopcount_tx(tx, fAccurate=True): | ||||
count = 0 | count = 0 | ||||
for i in tx.vout: | for i in tx.vout: | ||||
count += i.scriptPubKey.GetSigOpCount(fAccurate) | count += i.scriptPubKey.GetSigOpCount(fAccurate) | ||||
for j in tx.vin: | for j in tx.vin: | ||||
# scriptSig might be of type bytes, so convert to CScript for the moment | # scriptSig might be of type bytes, so convert to CScript for the | ||||
# moment | |||||
count += CScript(j.scriptSig).GetSigOpCount(fAccurate) | count += CScript(j.scriptSig).GetSigOpCount(fAccurate) | ||||
return count | return count | ||||
def create_confirmed_utxos(node, count, age=101): | def create_confirmed_utxos(node, count, age=101): | ||||
""" | """ | ||||
Helper to create at least "count" utxos | Helper to create at least "count" utxos | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |