diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py index ccf2114dba..06b5bf9698 100755 --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -163,7 +163,7 @@ class BIP65Test(BitcoinTestFramework): # First we show that this tx is valid except for CLTV by getting it # rejected from the mempool for exactly that reason. spendtx_txid = spendtx.txid_hex - spendtx_wtxid = spendtx.getwtxid() + spendtx_wtxid = spendtx.wtxid_hex assert_equal( [{ 'txid': spendtx_txid, diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py index 01f8e544a7..9687b80de9 100755 --- a/test/functional/feature_dersig.py +++ b/test/functional/feature_dersig.py @@ -115,7 +115,7 @@ class BIP66Test(BitcoinTestFramework): # First we show that this tx is valid except for DERSIG by getting it # rejected from the mempool for exactly that reason. spendtx_txid = spendtx.txid_hex - spendtx_wtxid = spendtx.getwtxid() + spendtx_wtxid = spendtx.wtxid_hex assert_equal( [{ 'txid': spendtx_txid, diff --git a/test/functional/feature_segwit.py b/test/functional/feature_segwit.py index d5f794c241..967b9e1e6e 100755 --- a/test/functional/feature_segwit.py +++ b/test/functional/feature_segwit.py @@ -251,7 +251,7 @@ class SegWitTest(BitcoinTestFramework): tx1 = tx_from_hex(tx1_hex) # Check that wtxid is properly reported in mempool entry (txid1) - assert_equal(self.nodes[0].getmempoolentry(txid1)["wtxid"], tx1.getwtxid()) + assert_equal(self.nodes[0].getmempoolentry(txid1)["wtxid"], tx1.wtxid_hex) # Check that weight and vsize are properly reported in mempool entry (txid1) assert_equal(self.nodes[0].getmempoolentry(txid1)["vsize"], tx1.get_vsize()) @@ -267,7 +267,7 @@ class SegWitTest(BitcoinTestFramework): assert not tx.wit.is_null() # Check that wtxid is properly reported in mempool entry (txid2) - assert_equal(self.nodes[0].getmempoolentry(txid2)["wtxid"], tx.getwtxid()) + assert_equal(self.nodes[0].getmempoolentry(txid2)["wtxid"], tx.wtxid_hex) # Check that weight and vsize are properly reported in mempool entry (txid2) assert_equal(self.nodes[0].getmempoolentry(txid2)["vsize"], tx.get_vsize()) @@ -289,7 +289,7 @@ class SegWitTest(BitcoinTestFramework): assert txid3 in template_txids # Check that wtxid is properly reported in mempool entry (txid3) - assert_equal(self.nodes[0].getmempoolentry(txid3)["wtxid"], tx.getwtxid()) + assert_equal(self.nodes[0].getmempoolentry(txid3)["wtxid"], tx.wtxid_hex) # Check that weight and vsize are properly reported in mempool entry (txid3) assert_equal(self.nodes[0].getmempoolentry(txid3)["vsize"], tx.get_vsize()) diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index 326ad78686..81c6ea3e5d 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -454,7 +454,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): anchor_spend.vout.append(CTxOut(anchor_value - int(fee*COIN), script_to_p2wsh_script(CScript([OP_TRUE])))) anchor_spend.wit.vtxinwit.append(CTxInWitness()) # It's "segwit" but txid == wtxid since there is no witness data - assert_equal(anchor_spend.txid_hex, anchor_spend.getwtxid()) + assert_equal(anchor_spend.txid_hex, anchor_spend.wtxid_hex) self.check_mempool_result( result_expected=[{'txid': anchor_spend.txid_hex, 'allowed': True, 'vsize': anchor_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}], diff --git a/test/functional/mempool_accept_wtxid.py b/test/functional/mempool_accept_wtxid.py index ef99e9bddc..35983d8eb4 100755 --- a/test/functional/mempool_accept_wtxid.py +++ b/test/functional/mempool_accept_wtxid.py @@ -76,13 +76,13 @@ class MempoolWtxidTest(BitcoinTestFramework): child_one.vout.append(CTxOut(int(9.99996 * COIN), child_script_pubkey)) child_one.wit.vtxinwit.append(CTxInWitness()) child_one.wit.vtxinwit[0].scriptWitness.stack = [b'Preimage', b'\x01', witness_script] - child_one_wtxid = child_one.getwtxid() + child_one_wtxid = child_one.wtxid_hex child_one_txid = child_one.txid_hex # Create another identical transaction with witness solving second branch child_two = deepcopy(child_one) child_two.wit.vtxinwit[0].scriptWitness.stack = [b'', witness_script] - child_two_wtxid = child_two.getwtxid() + child_two_wtxid = child_two.wtxid_hex child_two_txid = child_two.txid_hex assert_equal(child_one_txid, child_two_txid) diff --git a/test/functional/mempool_ephemeral_dust.py b/test/functional/mempool_ephemeral_dust.py index 93bbbe9a45..fd77eac3e2 100755 --- a/test/functional/mempool_ephemeral_dust.py +++ b/test/functional/mempool_ephemeral_dust.py @@ -40,11 +40,11 @@ class EphemeralDustTest(BitcoinTestFramework): result["new_utxos"][0]["value"] = Decimal(result["tx"].vout[0].nValue) / COIN new_txid = result["tx"].txid_hex result["txid"] = new_txid - result["wtxid"] = result["tx"].getwtxid() + result["wtxid"] = result["tx"].wtxid_hex result["hex"] = result["tx"].serialize().hex() for new_utxo in result["new_utxos"]: new_utxo["txid"] = new_txid - new_utxo["wtxid"] = result["tx"].getwtxid() + new_utxo["wtxid"] = result["tx"].wtxid_hex result["new_utxos"].append({"txid": new_txid, "vout": len(result["tx"].vout) - 1, "value": Decimal(output_value) / COIN, "height": 0, "coinbase": False, "confirmations": 0}) diff --git a/test/functional/mempool_limit.py b/test/functional/mempool_limit.py index 791654a8c0..b9ee6a0a10 100755 --- a/test/functional/mempool_limit.py +++ b/test/functional/mempool_limit.py @@ -379,7 +379,7 @@ class MempoolLimitTest(BitcoinTestFramework): rich_parent_result = submitpackage_result["tx-results"][tx_rich["wtxid"]] poor_parent_result = submitpackage_result["tx-results"][tx_poor["wtxid"]] - child_result = submitpackage_result["tx-results"][tx_child["tx"].getwtxid()] + child_result = submitpackage_result["tx-results"][tx_child["tx"].wtxid_hex] assert_fee_amount(poor_parent_result["fees"]["base"], tx_poor["tx"].get_vsize(), relayfee) assert_equal(rich_parent_result["fees"]["base"], 0) assert_equal(child_result["fees"]["base"], DEFAULT_FEE) @@ -392,11 +392,11 @@ class MempoolLimitTest(BitcoinTestFramework): package_vsize = tx_poor["tx"].get_vsize() + tx_child["tx"].get_vsize() assert_fee_amount(package_fees, package_vsize, poor_parent_result["fees"]["effective-feerate"]) assert_fee_amount(package_fees, package_vsize, child_result["fees"]["effective-feerate"]) - assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], poor_parent_result["fees"]["effective-includes"]) - assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], child_result["fees"]["effective-includes"]) + assert_equal([tx_poor["wtxid"], tx_child["tx"].wtxid_hex], poor_parent_result["fees"]["effective-includes"]) + assert_equal([tx_poor["wtxid"], tx_child["tx"].wtxid_hex], child_result["fees"]["effective-includes"]) # The node will broadcast each transaction, still abiding by its peer's fee filter - peer.wait_for_broadcast([tx["tx"].getwtxid() for tx in package_txns]) + peer.wait_for_broadcast([tx["tx"].wtxid_hex for tx in package_txns]) self.log.info("Check a package that passes mempoolminfee but is evicted immediately after submission") mempoolmin_feerate = node.getmempoolinfo()["mempoolminfee"] diff --git a/test/functional/mempool_package_onemore.py b/test/functional/mempool_package_onemore.py index fd54a8c3e1..74c5e34520 100755 --- a/test/functional/mempool_package_onemore.py +++ b/test/functional/mempool_package_onemore.py @@ -60,8 +60,8 @@ class MempoolPackagesTest(BitcoinTestFramework): txns_hex = [tx.serialize().hex() for tx in txns] assert_equal(self.nodes[0].testmempoolaccept(txns_hex)[0]["reject-reason"], "too-long-mempool-chain") pkg_result = self.nodes[0].submitpackage(txns_hex) - assert "too-long-mempool-chain" in pkg_result["tx-results"][txns[0].getwtxid()]["error"] - assert_equal(pkg_result["tx-results"][txns[1].getwtxid()]["error"], "bad-txns-inputs-missingorspent") + assert "too-long-mempool-chain" in pkg_result["tx-results"][txns[0].wtxid_hex]["error"] + assert_equal(pkg_result["tx-results"][txns[1].wtxid_hex]["error"], "bad-txns-inputs-missingorspent") # But not if it chains directly off the first transaction self.nodes[0].sendrawtransaction(replaceable_tx["hex"]) # and the second chain should work just fine diff --git a/test/functional/mempool_reorg.py b/test/functional/mempool_reorg.py index 74a353ab01..c1de3d0d18 100755 --- a/test/functional/mempool_reorg.py +++ b/test/functional/mempool_reorg.py @@ -73,7 +73,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): # request very recent, unanounced transactions. assert_equal(len(peer1.get_invs()), 0) # It's too early to request these two transactions - requests_too_recent = msg_getdata([CInv(t=MSG_WTX, h=int(tx["tx"].getwtxid(), 16)) for tx in [tx_before_reorg, tx_child]]) + requests_too_recent = msg_getdata([CInv(t=MSG_WTX, h=int(tx["tx"].wtxid_hex, 16)) for tx in [tx_before_reorg, tx_child]]) peer1.send_and_ping(requests_too_recent) for _ in range(len(requests_too_recent.inv)): peer1.sync_with_ping() @@ -82,7 +82,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): assert "notfound" in peer1.last_message # Request the tx from the disconnected block - request_disconnected_tx = msg_getdata([CInv(t=MSG_WTX, h=int(tx_disconnected["tx"].getwtxid(), 16))]) + request_disconnected_tx = msg_getdata([CInv(t=MSG_WTX, h=int(tx_disconnected["tx"].wtxid_hex, 16))]) peer1.send_and_ping(request_disconnected_tx) # The tx from the disconnected block was never announced, and it entered the mempool later @@ -90,7 +90,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): assert_equal(len(peer1.get_invs()), 0) with p2p_lock: # However, the node will answer requests for the tx from the recently-disconnected block. - assert_equal(peer1.last_message["tx"].tx.getwtxid(),tx_disconnected["tx"].getwtxid()) + assert_equal(peer1.last_message["tx"].tx.wtxid_hex,tx_disconnected["tx"].wtxid_hex) self.nodes[1].setmocktime(int(time.time()) + 300) peer1.sync_with_ping() @@ -102,7 +102,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): last_tx_received = peer1.last_message["tx"] tx_after_reorg = self.wallet.send_self_transfer(from_node=self.nodes[1]) - request_after_reorg = msg_getdata([CInv(t=MSG_WTX, h=int(tx_after_reorg["tx"].getwtxid(), 16))]) + request_after_reorg = msg_getdata([CInv(t=MSG_WTX, h=int(tx_after_reorg["tx"].wtxid_hex, 16))]) assert tx_after_reorg["txid"] in self.nodes[1].getrawmempool() peer1.send_and_ping(request_after_reorg) with p2p_lock: diff --git a/test/functional/mempool_sigoplimit.py b/test/functional/mempool_sigoplimit.py index ab58fed9e5..23ddf0bac9 100755 --- a/test/functional/mempool_sigoplimit.py +++ b/test/functional/mempool_sigoplimit.py @@ -168,7 +168,7 @@ class BytesPerSigOpTest(BitcoinTestFramework): # When we actually try to submit, the parent makes it into the mempool, but the child would exceed ancestor vsize limits res = self.nodes[0].submitpackage([tx_parent.serialize().hex(), tx_child.serialize().hex()]) - assert "too-long-mempool-chain" in res["tx-results"][tx_child.getwtxid()]["error"] + assert "too-long-mempool-chain" in res["tx-results"][tx_child.wtxid_hex]["error"] assert tx_parent.txid_hex in self.nodes[0].getrawmempool() # Transactions are tiny in weight diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py index dca1f1ce7b..7b816fe272 100755 --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -349,7 +349,7 @@ class CompactBlocksTest(BitcoinTestFramework): assert_equal(entry.tx.txid_hex, block.vtx[entry.index].txid_hex) # And this checks the witness - assert_equal(entry.tx.getwtxid(), block.vtx[entry.index].getwtxid()) + assert_equal(entry.tx.wtxid_hex, block.vtx[entry.index].wtxid_hex) # Check that the cmpctblock message announced all the transactions. assert_equal(len(header_and_shortids.prefilled_txn) + len(header_and_shortids.shortids), len(block.vtx)) @@ -586,7 +586,7 @@ class CompactBlocksTest(BitcoinTestFramework): tx = test_node.last_message["blocktxn"].block_transactions.transactions.pop(0) assert_equal(tx.txid_hex, block.vtx[index].txid_hex) # Check that the witness matches - assert_equal(tx.getwtxid(), block.vtx[index].getwtxid()) + assert_equal(tx.wtxid_hex, block.vtx[index].wtxid_hex) test_node.last_message.pop("blocktxn", None) current_height -= 1 diff --git a/test/functional/p2p_leak_tx.py b/test/functional/p2p_leak_tx.py index a2eec49b72..a1a00751d1 100755 --- a/test/functional/p2p_leak_tx.py +++ b/test/functional/p2p_leak_tx.py @@ -44,7 +44,7 @@ class P2PLeakTxTest(BitcoinTestFramework): self.log.debug("Request transaction") inbound_peer.last_message.pop("tx", None) inbound_peer.send_and_ping(want_tx) - assert_equal(inbound_peer.last_message.get("tx").tx.getwtxid(), wtxid) + assert_equal(inbound_peer.last_message.get("tx").tx.wtxid_hex, wtxid) def test_notfound_on_replaced_tx(self): self.gen_node.disconnect_p2ps() @@ -57,7 +57,7 @@ class P2PLeakTxTest(BitcoinTestFramework): tx_b = tx_a["tx"] tx_b.vout[0].nValue -= 9000 self.gen_node.sendrawtransaction(tx_b.serialize().hex()) - inbound_peer.wait_until(lambda: "tx" in inbound_peer.last_message and inbound_peer.last_message.get("tx").tx.getwtxid() == tx_b.getwtxid()) + inbound_peer.wait_until(lambda: "tx" in inbound_peer.last_message and inbound_peer.last_message.get("tx").tx.wtxid_hex == tx_b.wtxid_hex) self.log.info("Re-request of tx_a after replacement is answered with notfound") req_vec = [ diff --git a/test/functional/p2p_opportunistic_1p1c.py b/test/functional/p2p_opportunistic_1p1c.py index c7d3a2de96..49171de82f 100755 --- a/test/functional/p2p_opportunistic_1p1c.py +++ b/test/functional/p2p_opportunistic_1p1c.py @@ -83,7 +83,7 @@ class PackageRelayTest(BitcoinTestFramework): peer_sender = node.add_p2p_connection(P2PInterface()) # 1. Child is received first (perhaps the low feerate parent didn't meet feefilter or the requests were sent to different nodes). It is missing an input. - high_child_wtxid_int = int(high_fee_child["tx"].getwtxid(), 16) + high_child_wtxid_int = int(high_fee_child["tx"].wtxid_hex, 16) peer_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=high_child_wtxid_int)])) peer_sender.wait_for_getdata([high_child_wtxid_int]) peer_sender.send_and_ping(msg_tx(high_fee_child["tx"])) @@ -112,7 +112,7 @@ class PackageRelayTest(BitcoinTestFramework): peer_ignored = node.add_outbound_p2p_connection(P2PInterface(), p2p_idx=2, connection_type="outbound-full-relay") # 1. Parent is relayed first. It is too low feerate. - parent_wtxid_int = int(low_fee_parent["tx"].getwtxid(), 16) + parent_wtxid_int = int(low_fee_parent["tx"].wtxid_hex, 16) peer_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=parent_wtxid_int)])) peer_sender.wait_for_getdata([parent_wtxid_int]) peer_sender.send_and_ping(msg_tx(low_fee_parent["tx"])) @@ -123,7 +123,7 @@ class PackageRelayTest(BitcoinTestFramework): assert "getdata" not in peer_ignored.last_message # 2. Child is relayed next. It is missing an input. - high_child_wtxid_int = int(high_fee_child["tx"].getwtxid(), 16) + high_child_wtxid_int = int(high_fee_child["tx"].wtxid_hex, 16) peer_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=high_child_wtxid_int)])) peer_sender.wait_for_getdata([high_child_wtxid_int]) peer_sender.send_and_ping(msg_tx(high_fee_child["tx"])) @@ -156,7 +156,7 @@ class PackageRelayTest(BitcoinTestFramework): self.log.info("Check that tx caches low fee parent + low fee child package rejections") # 1. Send parent, rejected for being low feerate. - parent_wtxid_int = int(low_fee_parent["tx"].getwtxid(), 16) + parent_wtxid_int = int(low_fee_parent["tx"].wtxid_hex, 16) peer_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=parent_wtxid_int)])) peer_sender.wait_for_getdata([parent_wtxid_int]) peer_sender.send_and_ping(msg_tx(low_fee_parent["tx"])) @@ -167,7 +167,7 @@ class PackageRelayTest(BitcoinTestFramework): assert "getdata" not in peer_ignored.last_message # 2. Send an (orphan) child that has a higher feerate, but not enough to bump the parent. - med_child_wtxid_int = int(med_fee_child["tx"].getwtxid(), 16) + med_child_wtxid_int = int(med_fee_child["tx"].wtxid_hex, 16) peer_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=med_child_wtxid_int)])) peer_sender.wait_for_getdata([med_child_wtxid_int]) peer_sender.send_and_ping(msg_tx(med_fee_child["tx"])) @@ -193,7 +193,7 @@ class PackageRelayTest(BitcoinTestFramework): assert med_fee_child["txid"] not in node.getrawmempool() # 5. Send the high feerate (orphan) child - high_child_wtxid_int = int(high_fee_child["tx"].getwtxid(), 16) + high_child_wtxid_int = int(high_fee_child["tx"].wtxid_hex, 16) peer_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=high_child_wtxid_int)])) peer_sender.wait_for_getdata([high_child_wtxid_int]) peer_sender.send_and_ping(msg_tx(high_fee_child["tx"])) @@ -229,7 +229,7 @@ class PackageRelayTest(BitcoinTestFramework): parent_sender = node.add_p2p_connection(P2PInterface()) # 1. Child is received first. It is missing an input. - child_wtxid_int = int(tx_orphan_bad_wit.getwtxid(), 16) + child_wtxid_int = int(tx_orphan_bad_wit.wtxid_hex, 16) bad_orphan_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=child_wtxid_int)])) bad_orphan_sender.wait_for_getdata([child_wtxid_int]) bad_orphan_sender.send_and_ping(msg_tx(tx_orphan_bad_wit)) @@ -270,7 +270,7 @@ class PackageRelayTest(BitcoinTestFramework): fake_parent_sender = node.add_p2p_connection(P2PInterface()) # 1. Child is received first. It is missing an input. - child_wtxid_int = int(high_fee_child["tx"].getwtxid(), 16) + child_wtxid_int = int(high_fee_child["tx"].wtxid_hex, 16) package_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=child_wtxid_int)])) package_sender.wait_for_getdata([child_wtxid_int]) package_sender.send_and_ping(msg_tx(high_fee_child["tx"])) @@ -292,7 +292,7 @@ class PackageRelayTest(BitcoinTestFramework): self.log.info("Check that fake parent does not cause orphan to be deleted and real package can still be submitted") # 5. Child-sending should not have been punished and the orphan should remain in orphanage. # It can send the "real" parent transaction, and the package is accepted. - parent_wtxid_int = int(low_fee_parent["tx"].getwtxid(), 16) + parent_wtxid_int = int(low_fee_parent["tx"].wtxid_hex, 16) package_sender.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=parent_wtxid_int)])) package_sender.wait_for_getdata([parent_wtxid_int]) package_sender.send_and_ping(msg_tx(low_fee_parent["tx"])) diff --git a/test/functional/p2p_orphan_handling.py b/test/functional/p2p_orphan_handling.py index 376770d28d..b0cb1331d3 100755 --- a/test/functional/p2p_orphan_handling.py +++ b/test/functional/p2p_orphan_handling.py @@ -128,11 +128,11 @@ class OrphanHandlingTest(BitcoinTestFramework): """Create package with 1 parent and 1 child, normal fees (no cpfp).""" parent = self.wallet.create_self_transfer() child = self.wallet.create_self_transfer(utxo_to_spend=parent['new_utxo']) - return child["tx"].getwtxid(), child["tx"], parent["tx"] + return child["tx"].wtxid_hex, child["tx"], parent["tx"] def relay_transaction(self, peer, tx): """Relay transaction using MSG_WTX""" - wtxid = int(tx.getwtxid(), 16) + wtxid = int(tx.wtxid_hex, 16) peer.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=wtxid)])) self.nodes[0].bumpmocktime(TXREQUEST_TIME_SKIP) peer.wait_for_getdata([wtxid]) @@ -150,7 +150,7 @@ class OrphanHandlingTest(BitcoinTestFramework): tx_bad_wit.wit.vtxinwit[0].scriptWitness.stack = [b'garbage'] assert_equal(tx["txid"], tx_bad_wit.txid_hex) - assert_not_equal(tx["wtxid"], tx_bad_wit.getwtxid()) + assert_not_equal(tx["wtxid"], tx_bad_wit.wtxid_hex) return tx_bad_wit @@ -184,7 +184,7 @@ class OrphanHandlingTest(BitcoinTestFramework): # Spy peer should not be able to query the node for the parent yet, since it hasn't been # announced / insufficient time has elapsed. - parent_inv = CInv(t=MSG_WTX, h=int(tx_parent_arrives["tx"].getwtxid(), 16)) + parent_inv = CInv(t=MSG_WTX, h=int(tx_parent_arrives["tx"].wtxid_hex, 16)) assert_equal(len(peer_spy.get_invs()), 0) peer_spy.assert_no_immediate_response(msg_getdata([parent_inv])) @@ -205,7 +205,7 @@ class OrphanHandlingTest(BitcoinTestFramework): self.log.info("Test orphan handling when a nonsegwit parent is known to be invalid") parent_low_fee_nonsegwit = self.wallet_nonsegwit.create_self_transfer(fee_rate=0) - assert_equal(parent_low_fee_nonsegwit["txid"], parent_low_fee_nonsegwit["tx"].getwtxid()) + assert_equal(parent_low_fee_nonsegwit["txid"], parent_low_fee_nonsegwit["tx"].wtxid_hex) parent_other = self.wallet_nonsegwit.create_self_transfer() child_nonsegwit = self.wallet_nonsegwit.create_self_transfer_multi( utxos_to_spend=[parent_other["new_utxo"], parent_low_fee_nonsegwit["new_utxo"]]) @@ -348,9 +348,9 @@ class OrphanHandlingTest(BitcoinTestFramework): assert_equal(inflight_parent_AB["txid"], inflight_parent_AB["wtxid"]) # Announce inflight_parent_AB and wait for getdata - peer_txrequest.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=int(inflight_parent_AB["tx"].getwtxid(), 16))])) + peer_txrequest.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=int(inflight_parent_AB["tx"].wtxid_hex, 16))])) self.nodes[0].bumpmocktime(NONPREF_PEER_TX_DELAY) - peer_txrequest.wait_for_getdata([int(inflight_parent_AB["tx"].getwtxid(), 16)]) + peer_txrequest.wait_for_getdata([int(inflight_parent_AB["tx"].wtxid_hex, 16)]) self.log.info("Test that the node does not request a parent if it has an in-flight txrequest") # Relay orphan child_A @@ -408,11 +408,11 @@ class OrphanHandlingTest(BitcoinTestFramework): self.log.info("Test that an orphan with rejected parents, along with any descendants, cannot be retried with an alternate witness") parent_low_fee_nonsegwit = self.wallet_nonsegwit.create_self_transfer(fee_rate=0) - assert_equal(parent_low_fee_nonsegwit["txid"], parent_low_fee_nonsegwit["tx"].getwtxid()) + assert_equal(parent_low_fee_nonsegwit["txid"], parent_low_fee_nonsegwit["tx"].wtxid_hex) child = self.wallet.create_self_transfer(utxo_to_spend=parent_low_fee_nonsegwit["new_utxo"]) grandchild = self.wallet.create_self_transfer(utxo_to_spend=child["new_utxo"]) - assert_not_equal(child["txid"], child["tx"].getwtxid()) - assert_not_equal(grandchild["txid"], grandchild["tx"].getwtxid()) + assert_not_equal(child["txid"], child["tx"].wtxid_hex) + assert_not_equal(grandchild["txid"], grandchild["tx"].wtxid_hex) # Relay the parent. It should be rejected because it pays 0 fees. self.relay_transaction(peer1, parent_low_fee_nonsegwit["tx"]) @@ -430,7 +430,7 @@ class OrphanHandlingTest(BitcoinTestFramework): assert_equal(0, len(node.getrawmempool())) assert not tx_in_orphanage(node, grandchild["tx"]) peer2.assert_never_requested(child["txid"]) - peer2.assert_never_requested(child["tx"].getwtxid()) + peer2.assert_never_requested(child["tx"].wtxid_hex) # The child should never be requested, even if announced again with potentially different witness. # Sync with ping to ensure orphans are reconsidered diff --git a/test/functional/p2p_permissions.py b/test/functional/p2p_permissions.py index 4a52d5bddf..543cd3194b 100755 --- a/test/functional/p2p_permissions.py +++ b/test/functional/p2p_permissions.py @@ -118,7 +118,7 @@ class P2PPermissionsTests(BitcoinTestFramework): self.log.debug("Check that node[1] will send the tx to node[0] even though it is already in the mempool") self.connect_nodes(1, 0) - with self.nodes[1].assert_debug_log(["Force relaying tx {} (wtxid={}) from peer=0".format(txid, tx.getwtxid())]): + with self.nodes[1].assert_debug_log(["Force relaying tx {} (wtxid={}) from peer=0".format(txid, tx.wtxid_hex)]): p2p_rebroadcast_wallet.send_txs_and_test([tx], self.nodes[1]) self.wait_until(lambda: txid in self.nodes[0].getrawmempool()) @@ -134,14 +134,14 @@ class P2PPermissionsTests(BitcoinTestFramework): [tx], self.nodes[1], success=False, - reject_reason='{} (wtxid={}) from peer=0 was not accepted: dust'.format(txid, tx.getwtxid()) + reject_reason='{} (wtxid={}) from peer=0 was not accepted: dust'.format(txid, tx.wtxid_hex) ) p2p_rebroadcast_wallet.send_txs_and_test( [tx], self.nodes[1], success=False, - reject_reason='Not relaying non-mempool transaction {} (wtxid={}) from forcerelay peer=0'.format(txid, tx.getwtxid()) + reject_reason='Not relaying non-mempool transaction {} (wtxid={}) from forcerelay peer=0'.format(txid, tx.wtxid_hex) ) def checkpermission(self, args, expectedPermissions): diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 799e31f961..0892d9d1a4 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -336,7 +336,7 @@ class SegWitTest(BitcoinTestFramework): # Verify the hash with witness differs from the txid # (otherwise our testing framework must be broken!) - assert_not_equal(tx.txid_hex, tx.getwtxid()) + assert_not_equal(tx.txid_hex, tx.wtxid_hex) # Construct a block that includes the transaction. block = self.build_next_block() @@ -615,7 +615,7 @@ class SegWitTest(BitcoinTestFramework): assert_equal(testres3, [{ 'txid': tx3.txid_hex, - 'wtxid': tx3.getwtxid(), + 'wtxid': tx3.wtxid_hex, 'allowed': True, 'vsize': tx3.get_vsize(), 'fees': { @@ -633,7 +633,7 @@ class SegWitTest(BitcoinTestFramework): assert_equal(testres3_replaced, [{ 'txid': tx3.txid_hex, - 'wtxid': tx3.getwtxid(), + 'wtxid': tx3.wtxid_hex, 'allowed': True, 'vsize': tx3.get_vsize(), 'fees': { @@ -1258,7 +1258,7 @@ class SegWitTest(BitcoinTestFramework): # Test that getrawtransaction returns correct witness information # hash, size, vsize raw_tx = self.nodes[0].getrawtransaction(tx3.txid_hex, 1) - assert_equal(raw_tx["hash"], tx3.getwtxid()) + assert_equal(raw_tx["hash"], tx3.wtxid_hex) assert_equal(raw_tx["size"], len(tx3.serialize_with_witness())) vsize = tx3.get_vsize() assert_equal(raw_tx["vsize"], vsize) diff --git a/test/functional/rpc_packages.py b/test/functional/rpc_packages.py index 6337117ff5..3947053c41 100755 --- a/test/functional/rpc_packages.py +++ b/test/functional/rpc_packages.py @@ -106,7 +106,7 @@ class RPCPackagesTest(BitcoinTestFramework): # Package validation is atomic: if the node cannot find a UTXO for any single tx in the package, # it terminates immediately to avoid unnecessary, expensive signature verification. package_bad = self.independent_txns_hex + [garbage_tx] - testres_bad = self.independent_txns_testres_blank + [{"txid": tx.txid_hex, "wtxid": tx.getwtxid(), "allowed": False, "reject-reason": "missing-inputs"}] + testres_bad = self.independent_txns_testres_blank + [{"txid": tx.txid_hex, "wtxid": tx.wtxid_hex, "allowed": False, "reject-reason": "missing-inputs"}] self.assert_testres_equal(package_bad, testres_bad) self.log.info("Check testmempoolaccept tells us when some transactions completed validation successfully") @@ -118,7 +118,7 @@ class RPCPackagesTest(BitcoinTestFramework): # have been fully validated, which is why the node returns full validation results for all # transactions here but empty results in other cases. tx_bad_sig_txid = tx_bad_sig.txid_hex - tx_bad_sig_wtxid = tx_bad_sig.getwtxid() + tx_bad_sig_wtxid = tx_bad_sig.wtxid_hex assert_equal(testres_bad_sig, self.independent_txns_testres + [{ "txid": tx_bad_sig_txid, "wtxid": tx_bad_sig_wtxid, "allowed": False, @@ -146,7 +146,7 @@ class RPCPackagesTest(BitcoinTestFramework): self.log.info("Check that testmempoolaccept requires packages to be sorted by dependency") assert_equal(node.testmempoolaccept(rawtxs=chain_hex[::-1]), - [{"txid": tx.txid_hex, "wtxid": tx.getwtxid(), "package-error": "package-not-sorted"} for tx in chain_txns[::-1]]) + [{"txid": tx.txid_hex, "wtxid": tx.wtxid_hex, "package-error": "package-not-sorted"} for tx in chain_txns[::-1]]) self.log.info("Testmempoolaccept a chain of 25 transactions") testres_multiple = node.testmempoolaccept(rawtxs=chain_hex) @@ -353,8 +353,8 @@ class RPCPackagesTest(BitcoinTestFramework): assert_equal(submitpackage_result["package_msg"], "success") for package_txn in package_txns: tx = package_txn["tx"] - assert tx.getwtxid() in submitpackage_result["tx-results"] - wtxid = tx.getwtxid() + assert tx.wtxid_hex in submitpackage_result["tx-results"] + wtxid = tx.wtxid_hex assert wtxid in submitpackage_result["tx-results"] tx_result = submitpackage_result["tx-results"][wtxid] assert_equal(tx_result["txid"], tx.txid_hex) @@ -368,7 +368,7 @@ class RPCPackagesTest(BitcoinTestFramework): self.assert_equal_package_results(node, testmempoolaccept_result, submitpackage_result) # The node should announce each transaction. No guarantees for propagation. - peer.wait_for_broadcast([tx["tx"].getwtxid() for tx in package_txns]) + peer.wait_for_broadcast([tx["tx"].wtxid_hex for tx in package_txns]) self.generate(node, 1) def test_submitpackage(self): @@ -410,9 +410,9 @@ class RPCPackagesTest(BitcoinTestFramework): hex_partial_acceptance = [txs[0]["hex"], bad_child.serialize().hex()] res = node.submitpackage(hex_partial_acceptance) assert_equal(res["package_msg"], "transaction failed") - first_wtxid = txs[0]["tx"].getwtxid() + first_wtxid = txs[0]["tx"].wtxid_hex assert "error" not in res["tx-results"][first_wtxid] - sec_wtxid = bad_child.getwtxid() + sec_wtxid = bad_child.wtxid_hex assert_equal(res["tx-results"][sec_wtxid]["error"], "version") peer.wait_for_broadcast([first_wtxid]) @@ -496,7 +496,7 @@ class RPCPackagesTest(BitcoinTestFramework): # Relax the restrictions for both and send it; parent gets through as own subpackage pkg_result = node.submitpackage(chained_burn_hex, maxfeerate=minrate_btc_kvb_burn, maxburnamount=chained_txns_burn[1]["new_utxo"]["value"]) assert "error" not in pkg_result["tx-results"][chained_txns_burn[0]["wtxid"]] - assert_equal(pkg_result["tx-results"][tx.getwtxid()]["error"], "scriptpubkey") + assert_equal(pkg_result["tx-results"][tx.wtxid_hex]["error"], "scriptpubkey") assert_equal(node.getrawmempool(), [chained_txns_burn[0]["txid"]]) if __name__ == "__main__": diff --git a/test/functional/test_framework/mempool_util.py b/test/functional/test_framework/mempool_util.py index bacd987a54..1955b2637e 100644 --- a/test/functional/test_framework/mempool_util.py +++ b/test/functional/test_framework/mempool_util.py @@ -104,5 +104,5 @@ def fill_mempool(test_framework, node, *, tx_sync_fun=None): def tx_in_orphanage(node, tx: CTransaction) -> bool: """Returns true if the transaction is in the orphanage.""" - found = [o for o in node.getorphantxs(verbosity=1) if o["txid"] == tx.txid_hex and o["wtxid"] == tx.getwtxid()] + found = [o for o in node.getorphantxs(verbosity=1) if o["txid"] == tx.txid_hex and o["wtxid"] == tx.wtxid_hex] return len(found) == 1 diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 2b4e3bc596..b107fa1574 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -657,7 +657,8 @@ class CTransaction: def serialize(self): return self.serialize_with_witness() - def getwtxid(self): + @property + def wtxid_hex(self): """Return wtxid (transaction hash with witness) as hex string.""" return hash256(self.serialize())[::-1].hex() diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index 98c691d96a..ab462f79a2 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -287,7 +287,7 @@ class MiniWallet: return { "sent_vout": 1, "txid": txid, - "wtxid": tx.getwtxid(), + "wtxid": tx.wtxid_hex, "hex": tx.serialize().hex(), "tx": tx, } @@ -352,7 +352,7 @@ class MiniWallet: ) for i in range(len(tx.vout))], "fee": fee, "txid": txid, - "wtxid": tx.getwtxid(), + "wtxid": tx.wtxid_hex, "hex": tx.serialize().hex(), "tx": tx, }