Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | if len(utxos) < num: | ||||
utxos.extend(node.listunspent()) | utxos.extend(node.listunspent()) | ||||
send_big_transactions(node, utxos, num, 100) | send_big_transactions(node, utxos, num, 100) | ||||
node.generate(1) | node.generate(1) | ||||
def send_big_transactions(node, utxos, num, fee_multiplier): | def send_big_transactions(node, utxos, num, fee_multiplier): | ||||
from .cashaddr import decode | from .cashaddr import decode | ||||
txids = [] | txids = [] | ||||
padding = "1"*512 | padding = "1" * 512 | ||||
addrHash = decode(node.getnewaddress())[2] | addrHash = decode(node.getnewaddress())[2] | ||||
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) | ||||
ctx.vin.append(CTxIn(COutPoint(txid, int(utxo["vout"])), b"")) | ctx.vin.append(CTxIn(COutPoint(txid, int(utxo["vout"])), b"")) | ||||
ctx.vout.append( | ctx.vout.append( | ||||
CTxOut(int(satoshi_round(utxo['amount']*COIN)), | CTxOut(int(satoshi_round(utxo['amount'] * COIN)), | ||||
CScript([OP_DUP, OP_HASH160, addrHash, OP_EQUALVERIFY, OP_CHECKSIG]))) | CScript([OP_DUP, OP_HASH160, addrHash, OP_EQUALVERIFY, OP_CHECKSIG]))) | ||||
for i in range(0, 127): | for i in range(0, 127): | ||||
ctx.vout.append(CTxOut(0, CScript( | ctx.vout.append(CTxOut(0, CScript( | ||||
[OP_RETURN, bytes(padding, 'utf-8')]))) | [OP_RETURN, bytes(padding, 'utf-8')]))) | ||||
# Create a proper fee for the transaction to be mined | # Create a proper fee for the transaction to be mined | ||||
ctx.vout[0].nValue -= int(fee_multiplier * node.calculate_fee(ctx)) | ctx.vout[0].nValue -= int(fee_multiplier * node.calculate_fee(ctx)) | ||||
signresult = node.signrawtransactionwithwallet( | signresult = node.signrawtransactionwithwallet( | ||||
ToHex(ctx), None, "NONE|FORKID") | ToHex(ctx), None, "NONE|FORKID") | ||||
txid = node.sendrawtransaction(signresult["hex"], True) | txid = node.sendrawtransaction(signresult["hex"], True) | ||||
txids.append(txid) | txids.append(txid) | ||||
return txids | return txids |