Permalink
Browse files

RPC: add transaction hash to mempool entry output

  • Loading branch information...
luke-jr committed Sep 2, 2017
1 parent 092defc commit 5aa89bcd82ecb780161530137252eb677805a2d2
Showing with 8 additions and 3 deletions.
  1. +2 −0 src/rpc/blockchain.cpp
  2. +6 −3 test/functional/feature_segwit.py
@@ -368,6 +368,7 @@ static std::string EntryDescriptionString()
" \"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"
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)\n"
" \"hash\" : hash, (string) hash of entire serialized transaction\n"
" \"wtxid\" : hash, (string) hash of serialized transaction, including witness data\n"
" \"fees\" : {\n"
" \"base\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
@@ -407,6 +408,7 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
info.pushKV("ancestorsize", e.GetSizeWithAncestors());
info.pushKV("ancestorfees", e.GetModFeesWithAncestors());
info.pushKV("wtxid", mempool.vTxHashes[e.vTxHashesIdx].first.ToString());
info.pushKV("hash", info["wtxid"]);
const CTransaction& tx = e.GetTx();
std::set<std::string> setDepends;
for (const CTxIn& txin : tx.vin)
@@ -207,7 +207,8 @@ def run_test(self):
tx1_hex = self.nodes[0].gettransaction(txid1)['hex']
tx1 = FromHex(CTransaction(), tx1_hex)

# Check that wtxid is properly reported in mempool entry (txid1)
# Check that hash and wtxid are properly reported in mempool entry (txid1)
assert_equal(int(self.nodes[0].getmempoolentry(txid1)["hash"], 16), tx1.calc_sha256(True))
assert_equal(int(self.nodes[0].getmempoolentry(txid1)["wtxid"], 16), tx1.calc_sha256(True))

# Check that weight and size (actually vsize) are properly reported in mempool entry (txid1)
@@ -223,7 +224,8 @@ def run_test(self):
tx = FromHex(CTransaction(), tx2_hex)
assert(not tx.wit.is_null())

# Check that wtxid is properly reported in mempool entry (txid2)
# Check that hash and wtxid are properly reported in mempool entry (txid2)
assert_equal(int(self.nodes[0].getmempoolentry(txid2)["hash"], 16), tx.calc_sha256(True))
assert_equal(int(self.nodes[0].getmempoolentry(txid2)["wtxid"], 16), tx.calc_sha256(True))

# Check that weight and size (actually vsize) are properly reported in mempool entry (txid2)
@@ -254,7 +256,8 @@ def run_test(self):
assert(txid2 in template_txids)
assert(txid3 in template_txids)

# Check that wtxid is properly reported in mempool entry (txid3)
# Check that hash and wtxid are properly reported in mempool entry (txid3)
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["hash"], 16), tx.calc_sha256(True))
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["wtxid"], 16), tx.calc_sha256(True))

# Check that weight and size (actually vsize) are properly reported in mempool entry (txid3)

0 comments on commit 5aa89bc

Please sign in to comment.