diff options
author | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2018-01-25 19:03:05 +0900 |
---|---|---|
committer | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2018-04-06 13:34:12 +0900 |
commit | 891beb0f8a09810b179e39a680b579c2f6516db7 (patch) | |
tree | 808c26dc4fed68c1964bad194b70436e23626017 /test/functional/test_framework | |
parent | 6970b30c6f1d2be7947295fe18f2390649b17a4b (diff) |
[test] fundrawtransaction: lock watch-only shared address
self.nodes[0] creates an address which is watch-only-shared with self.nodes[3]. If nodes[0] spends the associated UTXO during any of its sends later, the watchonly test will fail, as nodes[3] now has insufficient funds.
Note that this also adds a new find_vout_for_address function to the test framework.
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r-- | test/functional/test_framework/util.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 7fdc171332..1320c8f029 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -569,3 +569,14 @@ def mine_large_block(node, utxos=None): fee = 100 * node.getnetworkinfo()["relayfee"] create_lots_of_big_transactions(node, txouts, utxos, num, fee=fee) node.generate(1) + +def find_vout_for_address(node, txid, addr): + """ + Locate the vout index of the given transaction sending to the + given address. Raises runtime error exception if not found. + """ + tx = node.getrawtransaction(txid, True) + for i in range(len(tx["vout"])): + if any([addr == a for a in tx["vout"][i]["scriptPubKey"]["addresses"]]): + return i + raise RuntimeError("Vout not found for address: txid=%s, addr=%s" % (txid, addr)) |