Skip to content

Commit 9d22dbe

Browse files
committed
Merge bitcoin/bitcoin#24198: wallet, rpc: add wtxid in WalletTxToJSON
7abd8b2 doc: include wtxid in TransactionDescriptionString (brunoerg) 2d596bc doc: add wtxid info in release-notes (brunoerg) a5b6673 test: add wtxid in expected_fields for wallet_basic (brunoerg) e8c659a wallet: add wtxid in WalletTxToJSON (brunoerg) 7482b6f wallet: add GetWitnessHash() (brunoerg) Pull request description: This PR add `wtxid` in `WalletTxToJSON` which allows to return this field in `listsinceblock`, `listtransactions` and `gettransaction` (RPCs). ACKs for top commit: achow101: re-ACK 7abd8b2 w0xlt: crACK 7abd8b2 luke-jr: re-utACK 7abd8b2 Tree-SHA512: f86f2dbb5e38e7b19932006121802f47b759d31bdbffe3263d1db464f6a3a30fddd68416f886a44f6d3a9fd570f7bd4f8d999737ad95c189e7ae5e8ec1ffbdaa
2 parents b07fdd7 + 7abd8b2 commit 9d22dbe

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

doc/release-notes-24198.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Updated RPCs
2+
------------
3+
4+
- The `listtransactions`, `gettransaction`, and `listsinceblock`
5+
RPC methods now include a wtxid field (hash of serialized transaction,
6+
including witness data) for each transaction.

src/wallet/rpc/transactions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue
3434
}
3535
uint256 hash = wtx.GetHash();
3636
entry.pushKV("txid", hash.GetHex());
37+
entry.pushKV("wtxid", wtx.GetWitnessHash().GetHex());
3738
UniValue conflicts(UniValue::VARR);
3839
for (const uint256& conflict : wallet.GetTxConflicts(wtx))
3940
conflicts.push_back(conflict.GetHex());
@@ -431,6 +432,7 @@ static const std::vector<RPCResult> TransactionDescriptionString()
431432
{RPCResult::Type::NUM, "blockindex", /*optional=*/true, "The index of the transaction in the block that includes it."},
432433
{RPCResult::Type::NUM_TIME, "blocktime", /*optional=*/true, "The block time expressed in " + UNIX_EPOCH_TIME + "."},
433434
{RPCResult::Type::STR_HEX, "txid", "The transaction id."},
435+
{RPCResult::Type::STR_HEX, "wtxid", "The hash of serialized transaction, including witness data."},
434436
{RPCResult::Type::ARR, "walletconflicts", "Conflicting transaction ids.",
435437
{
436438
{RPCResult::Type::STR_HEX, "txid", "The transaction id."},

src/wallet/transaction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ class CWalletTx
296296
bool isUnconfirmed() const { return !isAbandoned() && !isConflicted() && !isConfirmed(); }
297297
bool isConfirmed() const { return state<TxStateConfirmed>(); }
298298
const uint256& GetHash() const { return tx->GetHash(); }
299+
const uint256& GetWitnessHash() const { return tx->GetWitnessHash(); }
299300
bool IsCoinBase() const { return tx->IsCoinBase(); }
300301

301302
// Disable copying of CWalletTx objects to prevent bugs where instances get

test/functional/wallet_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def run_test(self):
668668
"category": baz["category"],
669669
"vout": baz["vout"]}
670670
expected_fields = frozenset({'amount', 'bip125-replaceable', 'confirmations', 'details', 'fee',
671-
'hex', 'time', 'timereceived', 'trusted', 'txid', 'walletconflicts'})
671+
'hex', 'time', 'timereceived', 'trusted', 'txid', 'wtxid', 'walletconflicts'})
672672
verbose_field = "decoded"
673673
expected_verbose_fields = expected_fields | {verbose_field}
674674

0 commit comments

Comments
 (0)