Skip to content

Commit d745b4c

Browse files
committed
Merge #11203: rpc: add wtxid to mempool entry output
617c459 qa: rpc test for wtxid in mempool entry (Suhas Daftuar) 7e5d596 RPC: add wtxid to mempool entry output (Suhas Daftuar) Pull request description: We already cache this information in the mempool, so including it in the output of rpc calls is basically free. Tree-SHA512: 2757e1bfca028103937e4b76ce1a5d805846bad5d3d9dd631dcc5f87721bcc0e9d19e437e02053ef1dd3b38b503f0fca8c0b8492cac37dfbd70256a3665f704c
2 parents 59e1789 + 617c459 commit d745b4c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ std::string EntryDescriptionString()
343343
" \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n"
344344
" \"ancestorsize\" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)\n"
345345
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n"
346+
" \"wtxid\" : hash, (string) hash of serialized transaction, including witness data\n"
346347
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
347348
" \"transactionid\", (string) parent transaction id\n"
348349
" ... ]\n";
@@ -363,6 +364,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
363364
info.push_back(Pair("ancestorcount", e.GetCountWithAncestors()));
364365
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors()));
365366
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
367+
info.push_back(Pair("wtxid", mempool.vTxHashes[e.vTxHashesIdx].first.ToString()));
366368
const CTransaction& tx = e.GetTx();
367369
std::set<std::string> setDepends;
368370
for (const CTxIn& txin : tx.vin)

test/functional/segwit.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ def run_test(self):
279279
assert(txid2 in template_txids)
280280
assert(txid3 in template_txids)
281281

282+
# Check that wtxid is properly reported in mempool entry
283+
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["wtxid"], 16), tx.calc_sha256(True))
284+
282285
# Mine a block to clear the gbt cache again.
283286
self.nodes[0].generate(1)
284287

0 commit comments

Comments
 (0)