From abe40712ce25f2383e60db9bfeb59d02473502ec Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 12 Apr 2016 15:31:19 -0400 Subject: [PATCH] rpc: include height in spentinfo --- qa/rpc-tests/spentindex.py | 2 ++ src/rpcmisc.cpp | 1 + src/rpcrawtransaction.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/qa/rpc-tests/spentindex.py b/qa/rpc-tests/spentindex.py index 44ba28660..6669df462 100755 --- a/qa/rpc-tests/spentindex.py +++ b/qa/rpc-tests/spentindex.py @@ -66,11 +66,13 @@ class SpentIndexTest(BitcoinTestFramework): info = self.nodes[1].getspentinfo({"txid": unspent[0]["txid"], "index": unspent[0]["vout"]}) assert_equal(info["txid"], txid) assert_equal(info["index"], 0) + assert_equal(info["height"], 106) # Check that verbose raw transaction includes spent info txVerbose = self.nodes[3].getrawtransaction(unspent[0]["txid"], 1) assert_equal(txVerbose["vout"][unspent[0]["vout"]]["spentTxId"], txid) assert_equal(txVerbose["vout"][unspent[0]["vout"]]["spentIndex"], 0) + assert_equal(txVerbose["vout"][unspent[0]["vout"]]["spentHeight"], 106) print "Passed\n" diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b31864993..fc55f3df2 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -737,6 +737,7 @@ UniValue getspentinfo(const UniValue& params, bool fHelp) UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", value.txid.GetHex())); obj.push_back(Pair("index", (int)value.inputIndex)); + obj.push_back(Pair("height", value.blockHeight)); return obj; } diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 0e8df7fae..6fbec480e 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -99,6 +99,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) if (GetSpentIndex(spentKey, spentInfo)) { out.push_back(Pair("spentTxId", spentInfo.txid.GetHex())); out.push_back(Pair("spentIndex", (int)spentInfo.inputIndex)); + out.push_back(Pair("spentHeight", spentInfo.blockHeight)); } vout.push_back(out);