Browse Source

Add block "confirmations" to getblock, mainly for identifying orphans

0.8
Luke Dashjr 13 years ago
parent
commit
d4e09300f3
  1. 3
      src/bitcoinrpc.cpp

3
src/bitcoinrpc.cpp

@ -172,6 +172,9 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
{ {
Object result; Object result;
result.push_back(Pair("hash", block.GetHash().GetHex())); result.push_back(Pair("hash", block.GetHash().GetHex()));
CMerkleTx txGen(block.vtx[0]);
txGen.SetMerkleBranch(&block);
result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight)); result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion)); result.push_back(Pair("version", block.nVersion));

Loading…
Cancel
Save