Skip to content

Commit 8ceb4ef

Browse files
achow101vijaydasmp
authored andcommitted
Merge bitcoin#28264: test: refactor: support sending funds with outpoint result
50d1ac1 test: remove unused `find_output` helper (Sebastian Falbesoner) 73a339a test: refactor: support sending funds with outpoint result (Sebastian Falbesoner) Pull request description: In wallet-related functional tests we often want to send funds to an address and use the resulting (non-change) UTXO directly after as input for another transaction. Doing that is currently tedious, as it involves finding the index part of the outpoint manually by calling helpers like `find_vout_for_address` or `find_output` first. This results in two different txid/vout variables which then again have to be combined to a single dictionary `{"txid": ..., "vout": ...}` in order to be specified as input for RPCs like `createrawtransaction` or `createpsbt`. For example: ``` txid1 = node1.sendtoaddress(addr1, value1) vout1 = find_vout_for_address(node1, txid1, addr1) txid2 = node2.sendtoaddress(addr2, value2) vout2 = find_vout_for_address(node2, txid2, addr2) node.createrawtransaction([{'txid': txid1, 'vout': vout1}, {'txid': txid2, 'vout': vout2}], .....) ``` This PR introduces a helper `create_outpoints` to immediately return the outpoint as UTXO dictionary in the common format, making the tests more readable and avoiding unnecessary duplication: ``` utxo1 = self.create_outpoints(node1, outputs=[{addr1: value1}])[0] utxo2 = self.create_outpoints(node2, outputs=[{addr2: value2}])[0] node.createrawtransaction([utxo1, utxo2], .....) ``` Tests are switched to work with UTXO-objects rather than two individual txid/vout variables accordingly. The `find_output` helper is removed, as it seems generally a bad idea to search for an outpoint only based on the output value. If that's really ever needed in the future, it makes probably more sense to add it as an additional parameter to `find_vout_of_address`. Note that `find_output` supported specifying a block-hash for where to look for the transaction (being passed on to the `getrawtransaction` RPC). This seems to be unneeded, as txids are always unique and for the only test that used that parameter (rpc_psbt.py) there was no observed difference in run-time, so it was not reintroduced in the new helper. There are still some `find_vout_of_address` calls remaining, used for detecting change outputs or for whenever the sending happens via `sendrawtransaction` instead, so this PR tackles not all, but the most common case. ACKs for top commit: achow101: ACK 50d1ac1 BrandonOdiwuor: ACK 50d1ac1 maflcko: ACK 50d1ac1 🖨 Tree-SHA512: af2bbf13a56cc840fefc1781390cf51625f1e41b3c030f07fc9abb1181b2d414ddbf795e887db029e119cbe45de14f7c987c0cba72ff0b8953080ee218a7915a
1 parent 5fd84aa commit 8ceb4ef

9 files changed

Lines changed: 100 additions & 110 deletions

test/functional/rpc_psbt.py

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
assert_equal,
3232
assert_greater_than,
3333
assert_raises_rpc_error,
34-
find_output,
3534
random_bytes,
3635
)
3736
from test_framework.wallet_util import bytes_to_wif
@@ -253,16 +252,17 @@ def run_test(self):
253252
self.nodes[0].converttopsbt(hexstring=signedtx['hex'], permitsigdata=True)
254253

255254
# Create outputs to nodes 1 and 2
255+
# (note that we intentionally create two different txs here, as we want
256+
# to check that each node is missing prevout data for one of the two
257+
# utxos, see "should only have data for one input" test below)
256258
node1_addr = self.nodes[1].getnewaddress()
257259
node2_addr = self.nodes[2].getnewaddress()
258-
txid1 = self.nodes[0].sendtoaddress(node1_addr, 13)
259-
txid2 = self.nodes[0].sendtoaddress(node2_addr, 13)
260-
blockhash = self.generate(self.nodes[0], 6)[0]
261-
vout1 = find_output(self.nodes[1], txid1, 13, blockhash=blockhash)
262-
vout2 = find_output(self.nodes[2], txid2, 13, blockhash=blockhash)
260+
utxo1 = self.create_outpoints(self.nodes[0], outputs=[{node1_addr: 13}])[0]
261+
utxo2 = self.create_outpoints(self.nodes[0], outputs=[{node2_addr: 13}])[0]
262+
self.generate(self.nodes[0], 6)[0]
263263

264264
# Create a psbt spending outputs from nodes 1 and 2
265-
psbt_orig = self.nodes[0].createpsbt([{"txid":txid1, "vout":vout1}, {"txid":txid2, "vout":vout2}], {self.nodes[0].getnewaddress():25.999})
265+
psbt_orig = self.nodes[0].createpsbt([utxo1, utxo2], {self.nodes[0].getnewaddress():25.999})
266266

267267
# Update psbts, should only have data for one input and not the other
268268
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig, False, "ALL")['psbt']
@@ -377,23 +377,18 @@ def run_test(self):
377377
assert_raises_rpc_error(-22, "TX decode failed invalid base64", self.nodes[0].decodepsbt, ";definitely not base64;")
378378

379379
# Send to all types of addresses
380-
addr1 = self.nodes[1].getnewaddress()
381-
txid1 = self.nodes[0].sendtoaddress(addr1, 11)
382-
vout1 = find_output(self.nodes[0], txid1, 11)
383-
addr2 = self.nodes[1].getnewaddress()
384-
txid2 = self.nodes[0].sendtoaddress(addr2, 11)
385-
vout2 = find_output(self.nodes[0], txid2, 11)
386-
addr3 = self.nodes[1].getnewaddress()
387-
txid3 = self.nodes[0].sendtoaddress(addr3, 11)
388-
vout3 = find_output(self.nodes[0], txid3, 11)
380+
addr1 = self.nodes[1].getnewaddress("", "bech32")
381+
addr2 = self.nodes[1].getnewaddress("", "legacy")
382+
addr3 = self.nodes[1].getnewaddress("", "p2sh-segwit")
383+
utxo1, utxo2, utxo3 = self.create_outpoints(self.nodes[1], outputs=[{addr1: 11}, {addr2: 11}, {addr3: 11}])
389384
self.sync_all()
390385

391386
def test_psbt_input_keys(psbt_input, keys):
392387
"""Check that the psbt input has only the expected keys."""
393388
assert_equal(set(keys), set(psbt_input.keys()))
394389

395390
# Create a PSBT. None of the inputs are filled initially
396-
psbt = self.nodes[1].createpsbt([{"txid":txid1, "vout":vout1},{"txid":txid2, "vout":vout2},{"txid":txid3, "vout":vout3}], {self.nodes[0].getnewaddress():32.999})
391+
psbt = self.nodes[1].createpsbt([utxo1, utxo2, utxo3], {self.nodes[0].getnewaddress():32.999})
397392
decoded = self.nodes[1].decodepsbt(psbt)
398393
test_psbt_input_keys(decoded['inputs'][0], [])
399394
test_psbt_input_keys(decoded['inputs'][1], [])
@@ -416,15 +411,14 @@ def test_psbt_input_keys(psbt_input, keys):
416411
test_psbt_input_keys(decoded['inputs'][2], ['non_witness_utxo', 'bip32_derivs'])
417412

418413
# Two PSBTs with a common input should not be joinable
419-
psbt1 = self.nodes[1].createpsbt([{"txid":txid1, "vout":vout1}], {self.nodes[0].getnewaddress():Decimal('10.999')})
414+
psbt1 = self.nodes[1].createpsbt([utxo1], {self.nodes[0].getnewaddress():Decimal('10.999')})
420415
assert_raises_rpc_error(-8, "exists in multiple PSBTs", self.nodes[1].joinpsbts, [psbt1, updated])
421416

422417
# Join two distinct PSBTs
423-
addr4 = self.nodes[1].getnewaddress()
424-
txid4 = self.nodes[0].sendtoaddress(addr4, 5)
425-
vout4 = find_output(self.nodes[0], txid4, 5)
418+
addr4 = self.nodes[1].getnewaddress("", "p2sh-segwit")
419+
utxo4 = self.create_outpoints(self.nodes[0], outputs=[{addr4: 5}])[0]
426420
self.generate(self.nodes[0], 6)
427-
psbt2 = self.nodes[1].createpsbt([{"txid":txid4, "vout":vout4}], {self.nodes[0].getnewaddress():Decimal('4.999')})
421+
psbt2 = self.nodes[1].createpsbt([utxo4], {self.nodes[0].getnewaddress():Decimal('4.999')})
428422
psbt2 = self.nodes[1].walletprocesspsbt(psbt2)['psbt']
429423
psbt2_decoded = self.nodes[0].decodepsbt(psbt2)
430424
assert "final_scriptwitness" not in psbt2_decoded['inputs'][0] and "final_scriptSig" in psbt2_decoded['inputs'][0]
@@ -433,11 +427,11 @@ def test_psbt_input_keys(psbt_input, keys):
433427
assert len(joined_decoded['inputs']) == 4 and len(joined_decoded['outputs']) == 2 and "final_scriptwitness" not in joined_decoded['inputs'][3] and "final_scriptSig" not in joined_decoded['inputs'][3]
434428

435429
# Newly created PSBT needs UTXOs and updating
436-
addr = self.nodes[1].getnewaddress()
437-
txid = self.nodes[0].sendtoaddress(addr, 7)
438-
self.generate(self.nodes[0], 6)
439-
vout = find_output(self.nodes[0], txid, 7)
440-
psbt = self.nodes[1].createpsbt([{"txid":txid, "vout":vout}], {self.nodes[0].getnewaddress():Decimal('6.999')})
430+
addr = self.nodes[1].getnewaddress("", "p2sh-segwit")
431+
utxo = self.create_outpoints(self.nodes[0], outputs=[{addr: 7}])[0]
432+
addrinfo = self.nodes[1].getaddressinfo(addr)
433+
self.generate(self.nodes[0], 6)[0]
434+
psbt = self.nodes[1].createpsbt([utxo], {self.nodes[0].getnewaddress("", "p2sh-segwit"):Decimal('6.999')})
441435
analyzed = self.nodes[0].analyzepsbt(psbt)
442436
assert not analyzed['inputs'][0]['has_utxo'] and not analyzed['inputs'][0]['is_final'] and analyzed['inputs'][0]['next'] == 'updater' and analyzed['next'] == 'updater'
443437

@@ -637,6 +631,5 @@ def test_psbt_input_keys(psbt_input, keys):
637631
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [psbt1, psbt2])
638632
assert_equal(self.nodes[0].combinepsbt([psbt1, psbt1]), psbt1)
639633

640-
641634
if __name__ == '__main__':
642635
PSBTTest().main()

test/functional/test_framework/test_framework.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
check_json_precision,
4949
copy_datadir,
5050
force_finish_mnsync,
51+
find_vout_for_address,
5152
get_datadir_path,
5253
initialize_datadir,
5354
p2p_port,
@@ -823,6 +824,22 @@ def generatetodescriptor(self, generator, *args, sync_fun=None, **kwargs):
823824
sync_fun() if sync_fun else self.sync_all()
824825
return blocks
825826

827+
def create_outpoints(self, node, *, outputs):
828+
"""Send funds to a given list of `{address: amount}` targets using the bitcoind
829+
wallet and return the corresponding outpoints as a list of dictionaries
830+
`[{"txid": txid, "vout": vout1}, {"txid": txid, "vout": vout2}, ...]`.
831+
The result can be used to specify inputs for RPCs like `createrawtransaction`,
832+
`createpsbt`, `lockunspent` etc."""
833+
assert all(len(output.keys()) == 1 for output in outputs)
834+
send_res = node.send(outputs)
835+
assert send_res["complete"]
836+
utxos = []
837+
for output in outputs:
838+
address = list(output.keys())[0]
839+
vout = find_vout_for_address(node, send_res["txid"], address)
840+
utxos.append({"txid": send_res["txid"], "vout": vout})
841+
return utxos
842+
826843
def sync_blocks(self, nodes=None, wait=1, timeout=60):
827844
"""
828845
Wait until everybody has the same tip.

test/functional/test_framework/util.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -579,18 +579,6 @@ def get_mnemonic(node):
579579
#############################
580580

581581

582-
def find_output(node, txid, amount, *, blockhash=None):
583-
"""
584-
Return index to output of txid with value amount
585-
Raises exception if there is none.
586-
"""
587-
txdata = node.getrawtransaction(txid, 1, blockhash)
588-
for i in range(len(txdata["vout"])):
589-
if txdata["vout"][i]["value"] == amount:
590-
return i
591-
raise RuntimeError("find_output txid %s : %s not found" % (txid, str(amount)))
592-
593-
594582
# Create large OP_RETURN txouts that can be appended to a transaction
595583
# to make it large (helper for constructing large transactions). The
596584
# total serialized size of the txouts is about 66k vbytes.

test/functional/wallet_basic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
assert_greater_than,
1616
assert_raises_rpc_error,
1717
count_bytes,
18-
find_vout_for_address,
1918
)
2019
from test_framework.wallet_util import test_address
2120

@@ -507,10 +506,9 @@ def run_test(self):
507506
# Import address and private key to check correct behavior of spendable unspents
508507
# 1. Send some coins to generate new UTXO
509508
address_to_import = self.nodes[2].getnewaddress()
510-
txid = self.nodes[0].sendtoaddress(address_to_import, 1)
509+
utxo = self.create_outpoints(self.nodes[0], outputs=[{address_to_import: 1}])[0]
511510
self.sync_mempools(self.nodes[0:3])
512-
vout = find_vout_for_address(self.nodes[2], txid, address_to_import)
513-
self.nodes[2].lockunspent(False, [{"txid": txid, "vout": vout}])
511+
self.nodes[2].lockunspent(False, [utxo])
514512
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
515513

516514
self.log.info("Test sendtoaddress with fee_rate param (explicit fee rate in duff/B)")

test/functional/wallet_fundrawtransaction.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
assert_greater_than_or_equal,
2020
assert_raises_rpc_error,
2121
count_bytes,
22-
find_vout_for_address,
2322
satoshi_round,
23+
get_fee,
2424
)
2525
from test_framework.wallet_util import bytes_to_wif
2626

@@ -77,14 +77,13 @@ def unlock_utxos(self, wallet):
7777
Unlock all UTXOs except the watchonly one
7878
"""
7979
to_keep = []
80-
if self.watchonly_txid is not None and self.watchonly_vout is not None:
81-
to_keep.append({"txid": self.watchonly_txid, "vout": self.watchonly_vout})
80+
if self.watchonly_utxo is not None:
81+
to_keep.append(self.watchonly_utxo)
8282
wallet.lockunspent(True)
8383
wallet.lockunspent(False, to_keep)
8484

8585
def run_test(self):
86-
self.watchonly_txid = None
87-
self.watchonly_vout = None
86+
self.watchonly_utxo = None
8887
self.log.info("Connect nodes, set fees, generate blocks, and sync")
8988
self.min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
9089
# This test is not meant to test fee estimation and we'd like
@@ -149,11 +148,10 @@ def test_change_position(self):
149148
watchonly_pubkey = self.nodes[0].getaddressinfo(watchonly_address)["pubkey"]
150149
self.watchonly_amount = Decimal(2000)
151150
wwatch.importpubkey(watchonly_pubkey, "", True)
152-
self.watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, self.watchonly_amount)
151+
self.watchonly_utxo = self.create_outpoints(self.nodes[0], outputs=[{watchonly_address: self.watchonly_amount}])[0]
153152

154153
# Lock UTXO so nodes[0] doesn't accidentally spend it
155-
self.watchonly_vout = find_vout_for_address(self.nodes[0], self.watchonly_txid, watchonly_address)
156-
self.nodes[0].lockunspent(False, [{"txid": self.watchonly_txid, "vout": self.watchonly_vout}])
154+
self.nodes[0].lockunspent(False, [self.watchonly_utxo])
157155

158156
self.nodes[0].sendtoaddress(self.nodes[3].get_wallet_rpc(self.default_wallet_name).getnewaddress(), self.watchonly_amount / 10)
159157

@@ -691,7 +689,7 @@ def test_watchonly(self):
691689
result = wwatch.fundrawtransaction(rawtx, True)
692690
res_dec = self.nodes[0].decoderawtransaction(result["hex"])
693691
assert_equal(len(res_dec["vin"]), 1)
694-
assert_equal(res_dec["vin"][0]["txid"], self.watchonly_txid)
692+
assert_equal(res_dec["vin"][0]["txid"], self.watchonly_utxo['txid'])
695693

696694
assert "fee" in result.keys()
697695
assert_greater_than(result["changepos"], -1)
@@ -711,7 +709,7 @@ def test_all_watched_funds(self):
711709
result = wwatch.fundrawtransaction(rawtx, {'includeWatching': True, 'changeAddress': w3.getrawchangeaddress(), 'subtractFeeFromOutputs': [0]})
712710
res_dec = self.nodes[0].decoderawtransaction(result["hex"])
713711
assert_equal(len(res_dec["vin"]), 1)
714-
assert res_dec["vin"][0]["txid"] == self.watchonly_txid
712+
assert res_dec["vin"][0]["txid"] == self.watchonly_utxo['txid']
715713

716714
assert_greater_than(result["fee"], 0)
717715
assert_equal(result["changepos"], -1)
@@ -924,10 +922,9 @@ def test_subtract_fee_with_presets(self):
924922
self.log.info("Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient")
925923

926924
addr = self.nodes[0].getnewaddress()
927-
txid = self.nodes[0].sendtoaddress(addr, 10)
928-
vout = find_vout_for_address(self.nodes[0], txid, addr)
925+
utxo = self.create_outpoints(self.nodes[0], outputs=[{addr: 10}])[0]
929926

930-
rawtx = self.nodes[0].createrawtransaction([{'txid': txid, 'vout': vout}], [{self.nodes[0].getnewaddress(): 5}])
927+
rawtx = self.nodes[0].createrawtransaction([utxo], [{self.nodes[0].getnewaddress(): 5}])
931928
fundedtx = self.nodes[0].fundrawtransaction(rawtx, {'subtractFeeFromOutputs': [0]})
932929
signedtx = self.nodes[0].signrawtransactionwithwallet(fundedtx['hex'])
933930
self.nodes[0].sendrawtransaction(signedtx['hex'])
@@ -1031,10 +1028,9 @@ def test_include_unsafe(self):
10311028
addr = wallet.getnewaddress()
10321029
inputs = []
10331030
for i in range(0, 2):
1034-
txid = self.nodes[2].sendtoaddress(addr, 5)
1035-
self.sync_mempools()
1036-
vout = find_vout_for_address(wallet, txid, addr)
1037-
inputs.append((txid, vout))
1031+
utxo = self.create_outpoints(self.nodes[2], outputs=[{addr: 5}])[0]
1032+
inputs.append((utxo['txid'], utxo['vout']))
1033+
self.sync_mempools()
10381034

10391035
# Unsafe inputs are ignored by default.
10401036
rawtx = wallet.createrawtransaction([], [{self.nodes[2].getnewaddress(): 7.5}])

test/functional/wallet_importdescriptors.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from test_framework.util import (
2121
assert_equal,
2222
assert_raises_rpc_error,
23-
find_vout_for_address,
2423
)
2524
from test_framework.wallet_util import (
2625
get_generate_key,
@@ -463,12 +462,10 @@ def run_test(self):
463462
assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 999)
464463

465464
# generate some utxos for next tests
466-
txid = w0.sendtoaddress(addr, 10)
467-
vout = find_vout_for_address(self.nodes[0], txid, addr)
465+
utxo = self.create_outpoints(w0, outputs=[{addr: 10}])[0]
468466

469467
addr2 = wmulti_pub.getnewaddress('')
470-
txid2 = w0.sendtoaddress(addr2, 10)
471-
vout2 = find_vout_for_address(self.nodes[0], txid2, addr2)
468+
utxo2 = self.create_outpoints(w0, outputs=[{addr2: 10}])[0]
472469

473470
self.generate(self.nodes[0], 6)
474471
assert_equal(wmulti_pub.getbalance(), wmulti_priv.getbalance())
@@ -524,7 +521,7 @@ def run_test(self):
524521
assert_equal(res[1]['success'], True)
525522
assert_equal(res[1]['warnings'][0], 'Not all private keys provided. Some wallet functionality may return unexpected errors')
526523

527-
rawtx = self.nodes[1].createrawtransaction([{'txid': txid, 'vout': vout}], {w0.getnewaddress(): 9.999})
524+
rawtx = self.nodes[1].createrawtransaction([utxo], {w0.getnewaddress(): 9.999})
528525
tx_signed_1 = wmulti_priv1.signrawtransactionwithwallet(rawtx)
529526
assert_equal(tx_signed_1['complete'], False)
530527
tx_signed_2 = wmulti_priv2.signrawtransactionwithwallet(tx_signed_1['hex'])
@@ -586,7 +583,7 @@ def run_test(self):
586583
}])
587584
assert_equal(res[0]['success'], True)
588585

589-
rawtx = self.nodes[1].createrawtransaction([{'txid': txid2, 'vout': vout2}], {w0.getnewaddress(): 9.999})
586+
rawtx = self.nodes[1].createrawtransaction([utxo2], {w0.getnewaddress(): 9.999})
590587
tx = wmulti_priv3.signrawtransactionwithwallet(rawtx)
591588
assert_equal(tx['complete'], True)
592589
self.nodes[1].sendrawtransaction(tx['hex'])

test/functional/wallet_signrawtransactionwithwallet.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@
66

77
from test_framework.address import script_to_p2sh
88
from test_framework.test_framework import BitcoinTestFramework
9-
from test_framework.util import assert_equal, assert_raises_rpc_error, find_vout_for_address
10-
from test_framework.script import CScript, OP_CHECKSEQUENCEVERIFY, OP_CHECKLOCKTIMEVERIFY, OP_DROP, OP_TRUE
11-
12-
from decimal import Decimal, getcontext
9+
from test_framework.util import (
10+
assert_equal,
11+
assert_raises_rpc_error,
12+
)
13+
from test_framework.script import (
14+
CScript,
15+
OP_CHECKLOCKTIMEVERIFY,
16+
OP_CHECKSEQUENCEVERIFY,
17+
OP_DROP,
18+
OP_TRUE,
19+
)
20+
21+
from decimal import (
22+
Decimal,
23+
getcontext,
24+
)
1325

1426
class SignRawTransactionWithWalletTest(BitcoinTestFramework):
1527
def add_options(self, parser):
@@ -140,13 +152,12 @@ def test_signing_with_csv(self):
140152
address = script_to_p2sh(script)
141153

142154
# Fund that address and make the spend
143-
txid = self.nodes[0].sendtoaddress(address, 1)
144-
vout = find_vout_for_address(self.nodes[0], txid, address)
155+
utxo1 = self.create_outpoints(self.nodes[0], outputs=[{address: 1}])[0]
145156
self.generate(self.nodes[0], 1)
146-
utxo = self.nodes[0].listunspent()[0]
147-
amt = Decimal(1) + utxo["amount"] - Decimal(0.00001)
157+
utxo2 = self.nodes[0].listunspent()[0]
158+
amt = Decimal(1) + utxo2["amount"] - Decimal(0.00001)
148159
tx = self.nodes[0].createrawtransaction(
149-
[{"txid": txid, "vout": vout, "sequence": 1},{"txid": utxo["txid"], "vout": utxo["vout"]}],
160+
[{**utxo1, "sequence": 1},{"txid": utxo2["txid"], "vout": utxo2["vout"]}],
150161
[{self.nodes[0].getnewaddress(): amt}],
151162
self.nodes[0].getblockcount()
152163
)
@@ -170,13 +181,12 @@ def test_signing_with_cltv(self):
170181
address = script_to_p2sh(script)
171182

172183
# Fund that address and make the spend
173-
txid = self.nodes[0].sendtoaddress(address, 1)
174-
vout = find_vout_for_address(self.nodes[0], txid, address)
184+
utxo1 = self.create_outpoints(self.nodes[0], outputs=[{address: 1}])[0]
175185
self.generate(self.nodes[0], 1)
176-
utxo = self.nodes[0].listunspent()[0]
177-
amt = Decimal(1) + utxo["amount"] - Decimal(0.00001)
186+
utxo2 = self.nodes[0].listunspent()[0]
187+
amt = Decimal(1) + utxo2["amount"] - Decimal(0.00001)
178188
tx = self.nodes[0].createrawtransaction(
179-
[{"txid": txid, "vout": vout},{"txid": utxo["txid"], "vout": utxo["vout"]}],
189+
[utxo1, {"txid": utxo2["txid"], "vout": utxo2["vout"]}],
180190
[{self.nodes[0].getnewaddress(): amt}],
181191
self.nodes[0].getblockcount()
182192
)

0 commit comments

Comments
 (0)