Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | def get_legacy_sigopcount_tx(tx, fAccurate=True): | ||||
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 | ||||
# Helper to create at least "count" utxos | |||||
# Pass in a fee that is sufficient for relay and mining new transactions. | |||||
def create_confirmed_utxos(fee, node, count, age=101): | |||||
to_generate = int(0.5 * count) + age | |||||
while to_generate > 0: | |||||
node.generate(min(25, to_generate)) | |||||
to_generate -= 25 | |||||
utxos = node.listunspent() | |||||
iterations = count - len(utxos) | |||||
addr1 = node.getnewaddress() | |||||
addr2 = node.getnewaddress() | |||||
if iterations <= 0: | |||||
return utxos | |||||
for i in range(iterations): | |||||
t = utxos.pop() | |||||
inputs = [] | |||||
inputs.append({"txid": t["txid"], "vout": t["vout"]}) | |||||
outputs = {} | |||||
send_value = t['amount'] - fee | |||||
outputs[addr1] = satoshi_round(send_value / 2) | |||||
outputs[addr2] = satoshi_round(send_value / 2) | |||||
raw_tx = node.createrawtransaction(inputs, outputs) | |||||
signed_tx = node.signrawtransaction(raw_tx)["hex"] | |||||
node.sendrawtransaction(signed_tx) | |||||
while (node.getmempoolinfo()['size'] > 0): | |||||
node.generate(1) | |||||
utxos = node.listunspent() | |||||
assert(len(utxos) >= count) | |||||
return utxos | |||||
def send_big_transactions(node, utxos, num, fee_multiplier): | def send_big_transactions(node, utxos, num, fee_multiplier): | ||||
txids = [] | txids = [] | ||||
padding = "1"*(512*127) | padding = "1"*(512*127) | ||||
for _ in range(num): | for _ in range(num): | ||||
ctx = CTransaction() | ctx = CTransaction() | ||||
utxo = utxos.pop() | utxo = utxos.pop() | ||||
txid = int(utxo['txid'], 16) | txid = int(utxo['txid'], 16) | ||||
Show All 12 Lines |