aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/util.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-01 15:56:38 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-08 00:21:37 +0200
commit6e63e366d609312ab984b4439de2d59bb618620b (patch)
treee223685f43e642bf58b3345d011848fc9c9a1489 /test/functional/test_framework/util.py
parente638acf6970394f8eb1957366ad2d39512f33b31 (diff)
test: refactor: dedup utility function chain_transaction()
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r--test/functional/test_framework/util.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 462019566c..4b5d14ebf9 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -481,6 +481,24 @@ def create_confirmed_utxos(fee, node, count):
return utxos
+# Build a transaction that spends parent_txid:vout
+# Return amount sent
+def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs):
+ send_value = satoshi_round((value - fee)/num_outputs)
+ inputs = []
+ for (txid, vout) in zip(parent_txids, vouts):
+ inputs.append({'txid' : txid, 'vout' : vout})
+ outputs = {}
+ for _ in range(num_outputs):
+ outputs[node.getnewaddress()] = send_value
+ rawtx = node.createrawtransaction(inputs, outputs, 0, True)
+ signedtx = node.signrawtransactionwithwallet(rawtx)
+ txid = node.sendrawtransaction(signedtx['hex'])
+ fulltx = node.getrawtransaction(txid, 1)
+ assert len(fulltx['vout']) == num_outputs # make sure we didn't generate a change output
+ return (txid, send_value)
+
+
# Create large OP_RETURN txouts that can be appended to a transaction
# to make it large (helper for constructing large transactions).
def gen_return_txouts():