diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py index 2e8eb7803c..98d47da918 100755 --- a/test/functional/feature_coinstatsindex.py +++ b/test/functional/feature_coinstatsindex.py @@ -149,14 +149,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 2d4752565e..31d59f1a25 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -99,7 +99,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()) @@ -111,7 +111,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): diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py index c1b344c357..574bf3be7c 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 5354364ee8..73184af514 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -366,7 +366,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 cccf62ee98..f8b7e29f47 100755 --- a/test/functional/mempool_sigoplimit.py +++ b/test/functional/mempool_sigoplimit.py @@ -50,7 +50,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, @@ -58,7 +58,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), CTxOut(500000, b'')] # ELEMENTS fee diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py index b3e68ca536..6699cc3528 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 6846d2ee78..219896d8b0 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -195,8 +195,8 @@ class RpcCreateMultiSigTest(BitcoinTestFramework): # ELEMENTS: since we sent directly to node0 at the start of test, use node0 to send the funds, # instead of self.wallet - #spk = bytes.fromhex(node0.validateaddress(madd)["scriptPubKey"]) - #txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300) + # spk = address_to_scriptpubkey(madd) + # txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300)["txid"] txid = node0.sendtoaddress(madd, 40) tx = node0.getrawtransaction(txid, True) vout = [v["n"] for v in tx["vout"] if madd == v["scriptPubKey"].get("address")] diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index b0a34abb64..dcbeda4aec 100755 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -258,8 +258,6 @@ 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.getAmount(), amount + fee) @@ -267,7 +265,13 @@ class MiniWallet: tx.vout[1].nValue.setToAmount(fee) # ELEMENTS explicitly set fee output value 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, 2 + return { + "sent_vout": 2, + "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."""