Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 528 Lines • ▼ Show 20 Lines | def send_zeropri_transaction(from_node, to_node, amount, fee): | ||||
# Create a send-to-self with confirmed inputs: | # Create a send-to-self with confirmed inputs: | ||||
self_address = from_node.getnewaddress() | self_address = from_node.getnewaddress() | ||||
(total_in, inputs) = gather_inputs(from_node, amount + fee * 2) | (total_in, inputs) = gather_inputs(from_node, amount + fee * 2) | ||||
outputs = make_change(from_node, total_in, amount + fee, fee) | outputs = make_change(from_node, total_in, amount + fee, fee) | ||||
outputs[self_address] = float(amount + fee) | outputs[self_address] = float(amount + fee) | ||||
self_rawtx = from_node.createrawtransaction(inputs, outputs) | self_rawtx = from_node.createrawtransaction(inputs, outputs) | ||||
self_signresult = from_node.signrawtransaction(self_rawtx) | self_signresult = from_node.signrawtransactionwithwallet(self_rawtx) | ||||
self_txid = from_node.sendrawtransaction(self_signresult["hex"], True) | self_txid = from_node.sendrawtransaction(self_signresult["hex"], True) | ||||
vout = find_output(from_node, self_txid, amount + fee) | vout = find_output(from_node, self_txid, amount + fee) | ||||
# Now immediately spend the output to create a 1-input, 1-output | # Now immediately spend the output to create a 1-input, 1-output | ||||
# zero-priority transaction: | # zero-priority transaction: | ||||
inputs = [{"txid": self_txid, "vout": vout}] | inputs = [{"txid": self_txid, "vout": vout}] | ||||
outputs = {to_node.getnewaddress(): float(amount)} | outputs = {to_node.getnewaddress(): float(amount)} | ||||
rawtx = from_node.createrawtransaction(inputs, outputs) | rawtx = from_node.createrawtransaction(inputs, outputs) | ||||
signresult = from_node.signrawtransaction(rawtx) | signresult = from_node.signrawtransactionwithwallet(rawtx) | ||||
txid = from_node.sendrawtransaction(signresult["hex"], True) | txid = from_node.sendrawtransaction(signresult["hex"], True) | ||||
return (txid, signresult["hex"]) | return (txid, signresult["hex"]) | ||||
def random_zeropri_transaction(nodes, amount, min_fee, fee_increment, fee_variants): | def random_zeropri_transaction(nodes, amount, min_fee, fee_increment, fee_variants): | ||||
""" | """ | ||||
Create a random zero-priority transaction. | Create a random zero-priority transaction. | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | for k in range(128): | ||||
txouts = txouts + script_pubkey | txouts = txouts + script_pubkey | ||||
return txouts | return txouts | ||||
def create_tx(node, coinbase, to_address, amount): | def create_tx(node, coinbase, to_address, amount): | ||||
inputs = [{"txid": coinbase, "vout": 0}] | inputs = [{"txid": coinbase, "vout": 0}] | ||||
outputs = {to_address: amount} | outputs = {to_address: amount} | ||||
rawtx = node.createrawtransaction(inputs, outputs) | rawtx = node.createrawtransaction(inputs, outputs) | ||||
signresult = node.signrawtransaction(rawtx) | signresult = node.signrawtransactionwithwallet(rawtx) | ||||
assert_equal(signresult["complete"], True) | assert_equal(signresult["complete"], True) | ||||
return signresult["hex"] | return signresult["hex"] | ||||
# Create a spend of each passed-in utxo, splicing in "txouts" to each raw | # Create a spend of each passed-in utxo, splicing in "txouts" to each raw | ||||
# transaction to make it large. See gen_return_txouts() above. | # transaction to make it large. See gen_return_txouts() above. | ||||
def create_lots_of_big_transactions(node, txouts, utxos, num, fee): | def create_lots_of_big_transactions(node, txouts, utxos, num, fee): | ||||
Show All 17 Lines |