From d4e09300f3f9deb401e38fdf50fd0ff8d3f15b50 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 22 Feb 2012 13:26:25 -0500 Subject: [PATCH] Add block "confirmations" to getblock, mainly for identifying orphans --- src/bitcoinrpc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 54bec8623..7d2450c16 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -172,6 +172,9 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex) { Object result; 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("height", blockindex->nHeight)); result.push_back(Pair("version", block.nVersion));