From 7482b6f89500d9783cc6af0dccab7a08d0128206 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Wed, 26 Jan 2022 08:58:29 -0300 Subject: [PATCH 1/5] wallet: add GetWitnessHash() --- src/wallet/transaction.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 00f9c9f1544..271d698e56a 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -296,6 +296,7 @@ public: bool isUnconfirmed() const { return !isAbandoned() && !isConflicted() && !isConfirmed(); } bool isConfirmed() const { return state(); } const uint256& GetHash() const { return tx->GetHash(); } + const uint256& GetWitnessHash() const { return tx->GetWitnessHash(); } bool IsCoinBase() const { return tx->IsCoinBase(); } // Disable copying of CWalletTx objects to prevent bugs where instances get From e8c659a2970ec8855de3e1dbf91c6b614b8e5644 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Wed, 26 Jan 2022 08:58:53 -0300 Subject: [PATCH 2/5] wallet: add wtxid in WalletTxToJSON --- src/wallet/rpc/transactions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index eef2c13ee1d..28baa680f27 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -34,6 +34,7 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue } uint256 hash = wtx.GetHash(); entry.pushKV("txid", hash.GetHex()); + entry.pushKV("wtxid", wtx.GetWitnessHash().GetHex()); UniValue conflicts(UniValue::VARR); for (const uint256& conflict : wallet.GetTxConflicts(wtx)) conflicts.push_back(conflict.GetHex()); From a5b66738f19a0ad46d7bc287e0db08552c5a1fec Mon Sep 17 00:00:00 2001 From: brunoerg Date: Sat, 29 Jan 2022 15:39:12 -0300 Subject: [PATCH 3/5] test: add wtxid in expected_fields for wallet_basic --- test/functional/wallet_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 69f9df57d89..a7873838be5 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -668,7 +668,7 @@ class WalletTest(BitcoinTestFramework): "category": baz["category"], "vout": baz["vout"]} expected_fields = frozenset({'amount', 'bip125-replaceable', 'confirmations', 'details', 'fee', - 'hex', 'time', 'timereceived', 'trusted', 'txid', 'walletconflicts'}) + 'hex', 'time', 'timereceived', 'trusted', 'txid', 'wtxid', 'walletconflicts'}) verbose_field = "decoded" expected_verbose_fields = expected_fields | {verbose_field} From 2d596bce6fefeff6033b21b391e81f1dda846937 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Mon, 31 Jan 2022 08:31:49 -0300 Subject: [PATCH 4/5] doc: add wtxid info in release-notes --- doc/release-notes-24198.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 doc/release-notes-24198.md diff --git a/doc/release-notes-24198.md b/doc/release-notes-24198.md new file mode 100644 index 00000000000..e41b2a8e261 --- /dev/null +++ b/doc/release-notes-24198.md @@ -0,0 +1,6 @@ +Updated RPCs +------------ + +- The `listtransactions`, `gettransaction`, and `listsinceblock` + RPC methods now include a wtxid field (hash of serialized transaction, + including witness data) for each transaction. \ No newline at end of file From 7abd8b21ba34f6a42db2cd2d59a4c0e08561f609 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Mon, 31 Jan 2022 19:42:07 -0300 Subject: [PATCH 5/5] doc: include wtxid in TransactionDescriptionString --- src/wallet/rpc/transactions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index 28baa680f27..ad94ce4b32e 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -432,6 +432,7 @@ static const std::vector TransactionDescriptionString() {RPCResult::Type::NUM, "blockindex", /*optional=*/true, "The index of the transaction in the block that includes it."}, {RPCResult::Type::NUM_TIME, "blocktime", /*optional=*/true, "The block time expressed in " + UNIX_EPOCH_TIME + "."}, {RPCResult::Type::STR_HEX, "txid", "The transaction id."}, + {RPCResult::Type::STR_HEX, "wtxid", "The hash of serialized transaction, including witness data."}, {RPCResult::Type::ARR, "walletconflicts", "Conflicting transaction ids.", { {RPCResult::Type::STR_HEX, "txid", "The transaction id."},