Browse Source

Merge #11203: rpc: add wtxid to mempool entry output

617c459c6 qa: rpc test for wtxid in mempool entry (Suhas Daftuar)
7e5d5965d 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
0.16
Wladimir J. van der Laan 7 years ago
parent
commit
d745b4cf7b
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 2
      src/rpc/blockchain.cpp
  2. 3
      test/functional/segwit.py

2
src/rpc/blockchain.cpp

@ -343,6 +343,7 @@ std::string EntryDescriptionString()
" \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n" " \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n"
" \"ancestorsize\" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)\n" " \"ancestorsize\" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)\n"
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n" " \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n"
" \"wtxid\" : hash, (string) hash of serialized transaction, including witness data\n"
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n" " \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
" \"transactionid\", (string) parent transaction id\n" " \"transactionid\", (string) parent transaction id\n"
" ... ]\n"; " ... ]\n";
@ -363,6 +364,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
info.push_back(Pair("ancestorcount", e.GetCountWithAncestors())); info.push_back(Pair("ancestorcount", e.GetCountWithAncestors()));
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors())); info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors()));
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors())); info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
info.push_back(Pair("wtxid", mempool.vTxHashes[e.vTxHashesIdx].first.ToString()));
const CTransaction& tx = e.GetTx(); const CTransaction& tx = e.GetTx();
std::set<std::string> setDepends; std::set<std::string> setDepends;
for (const CTxIn& txin : tx.vin) for (const CTxIn& txin : tx.vin)

3
test/functional/segwit.py

@ -279,6 +279,9 @@ class SegWitTest(BitcoinTestFramework):
assert(txid2 in template_txids) assert(txid2 in template_txids)
assert(txid3 in template_txids) assert(txid3 in template_txids)
# Check that wtxid is properly reported in mempool entry
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["wtxid"], 16), tx.calc_sha256(True))
# Mine a block to clear the gbt cache again. # Mine a block to clear the gbt cache again.
self.nodes[0].generate(1) self.nodes[0].generate(1)

Loading…
Cancel
Save