rpc: include height in getrawtransaction results

This commit is contained in:
Braydon Fuller 2016-03-22 13:55:19 -04:00 committed by Simon
parent c4c22aefc3
commit 59568ff5e8
1 changed files with 4 additions and 2 deletions

View File

@ -166,12 +166,14 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
if (mi != mapBlockIndex.end() && (*mi).second) { if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) { if (chainActive.Contains(pindex)) {
entry.push_back(Pair("height", pindex->nHeight));
entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight)); entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight));
entry.push_back(Pair("time", pindex->GetBlockTime())); entry.push_back(Pair("time", pindex->GetBlockTime()));
entry.push_back(Pair("blocktime", pindex->GetBlockTime())); entry.push_back(Pair("blocktime", pindex->GetBlockTime()));
} } else {
else entry.push_back(Pair("height", -1));
entry.push_back(Pair("confirmations", 0)); entry.push_back(Pair("confirmations", 0));
}
} }
} }
} }