diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py index 4f8541a5d7d..679d3b84e09 100755 --- a/test/functional/feature_coinstatsindex.py +++ b/test/functional/feature_coinstatsindex.py @@ -145,14 +145,14 @@ class CoinStatsIndexTest(BitcoinTestFramework): self.block_sanity_check(res5['block_info']) # Generate and send a normal tx with two outputs - tx1_txid, tx1_vout = self.wallet.send_to( + tx1 = self.wallet.send_to( from_node=node, scriptPubKey=self.wallet.get_scriptPubKey(), amount=21 * COIN, ) # Find the right position of the 21 BTC output - tx1_out_21 = self.wallet.get_utxo(txid=tx1_txid, vout=tx1_vout) + tx1_out_21 = self.wallet.get_utxo(txid=tx1["txid"], vout=tx1["sent_vout"]) # Generate and send another tx with an OP_RETURN output (which is unspendable) tx2 = self.wallet.create_self_transfer(utxo_to_spend=tx1_out_21)['tx'] diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index 947d2e82738..c5eeaf66e02 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -93,7 +93,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): confirmed - txout created will be confirmed in the blockchain; unconfirmed otherwise. """ - txid, n = self.wallet.send_to(from_node=node, scriptPubKey=scriptPubKey or self.wallet.get_scriptPubKey(), amount=amount) + tx = self.wallet.send_to(from_node=node, scriptPubKey=scriptPubKey or self.wallet.get_scriptPubKey(), amount=amount) if confirmed: mempool_size = len(node.getrawmempool()) @@ -105,7 +105,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): assert new_size < mempool_size mempool_size = new_size - return self.wallet.get_utxo(txid=txid, vout=n) + return self.wallet.get_utxo(txid=tx["txid"], vout=tx["sent_vout"]) def test_simple_doublespend(self): """Simple doublespend""" diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py index 5017f77d18e..315d7179869 100755 --- a/test/functional/interface_rest.py +++ b/test/functional/interface_rest.py @@ -96,7 +96,7 @@ class RESTTest (BitcoinTestFramework): self.wallet = MiniWallet(self.nodes[0]) self.log.info("Broadcast test transaction and sync nodes") - txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN)) + txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))["txid"] self.sync_all() self.log.info("Test the /tx URI") @@ -173,7 +173,7 @@ class RESTTest (BitcoinTestFramework): # found with or without /checkmempool. # do a tx and don't sync - txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN)) + txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))["txid"] json_obj = self.test_rest_request(f"/tx/{txid}") # get the spent output to later check for utxo (should be spent by then) spent = (json_obj['vin'][0]['txid'], json_obj['vin'][0]['vout']) diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index 362b407062e..737a8d0a2eb 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -350,7 +350,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): self.log.info('A tiny transaction(in non-witness bytes) that is disallowed') tx = CTransaction() - tx.vin.append(CTxIn(COutPoint(int(seed_tx[0], 16), seed_tx[1]), b"", SEQUENCE_FINAL)) + tx.vin.append(CTxIn(COutPoint(int(seed_tx["txid"], 16), seed_tx["sent_vout"]), b"", SEQUENCE_FINAL)) tx.wit.vtxinwit = [CTxInWitness()] tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])] tx.vout.append(CTxOut(0, CScript([OP_RETURN] + ([OP_0] * (MIN_PADDING - 2))))) diff --git a/test/functional/mempool_sigoplimit.py b/test/functional/mempool_sigoplimit.py index b178b9feda6..962b2b19bd8 100755 --- a/test/functional/mempool_sigoplimit.py +++ b/test/functional/mempool_sigoplimit.py @@ -49,7 +49,7 @@ class BytesPerSigOpTest(BitcoinTestFramework): """Create a 1-input-1-output P2WSH spending transaction with only the witness script in the witness stack and the given output script.""" # create P2WSH address and fund it via MiniWallet first - txid, vout = self.wallet.send_to( + fund = self.wallet.send_to( from_node=self.nodes[0], scriptPubKey=script_to_p2wsh_script(witness_script), amount=1000000, @@ -57,7 +57,7 @@ class BytesPerSigOpTest(BitcoinTestFramework): # create spending transaction tx = CTransaction() - tx.vin = [CTxIn(COutPoint(int(txid, 16), vout))] + tx.vin = [CTxIn(COutPoint(int(fund["txid"], 16), fund["sent_vout"]))] tx.wit.vtxinwit = [CTxInWitness()] tx.wit.vtxinwit[0].scriptWitness.stack = [bytes(witness_script)] tx.vout = [CTxOut(500000, output_script)] diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py index b3e68ca536b..6699cc3528d 100755 --- a/test/functional/p2p_filter.py +++ b/test/functional/p2p_filter.py @@ -136,7 +136,7 @@ class FilterTest(BitcoinTestFramework): filter_peer = P2PBloomFilter() self.log.debug("Create a tx relevant to the peer before connecting") - txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN) + txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN)["txid"] self.log.debug("Send a mempool msg after connecting and check that the tx is received") self.nodes[0].add_p2p_connection(filter_peer) @@ -183,14 +183,14 @@ class FilterTest(BitcoinTestFramework): self.log.info('Check that we receive a tx if the filter matches a mempool tx') filter_peer.merkleblock_received = False - txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN) + txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN)["txid"] filter_peer.wait_for_tx(txid) assert not filter_peer.merkleblock_received self.log.info('Check that after deleting filter all txs get relayed again') filter_peer.send_and_ping(msg_filterclear()) for _ in range(5): - txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=7 * COIN) + txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=7 * COIN)["txid"] filter_peer.wait_for_tx(txid) self.log.info('Check that request for filtered blocks is ignored if no filter is set') diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index bec499107f8..279fb01a571 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -195,7 +195,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework): wmulti.unloadwallet() spk = address_to_scriptpubkey(madd) - txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300) + txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300)["txid"] tx = node0.getrawtransaction(txid, True) vout = [v["n"] for v in tx["vout"] if madd == v["scriptPubKey"]["address"]] assert len(vout) == 1 diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index fcd396c700f..64606b818b6 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -256,15 +256,19 @@ class MiniWallet: Note that this method fails if there is no single internal utxo available that can cover the cost for the amount and the fixed fee (the utxo with the largest value is taken). - - Returns a tuple (txid, n) referring to the created external utxo outpoint. """ tx = self.create_self_transfer(fee_rate=0)["tx"] assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee) tx.vout[0].nValue -= (amount + fee) # change output -> MiniWallet tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex()) - return txid, 1 + return { + "sent_vout": 1, + "txid": txid, + "wtxid": tx.getwtxid(), + "hex": tx.serialize().hex(), + "tx": tx, + } def send_self_transfer_multi(self, *, from_node, **kwargs): """Call create_self_transfer_multi and send the transaction."""