|
|
@ -54,9 +54,11 @@ 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]); |
|
|
|
int confirmations = -1; |
|
|
|
txGen.SetMerkleBranch(&block); |
|
|
|
// Only report confirmations if the block is on the main chain
|
|
|
|
result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain())); |
|
|
|
if (chainActive.Contains(blockindex)) |
|
|
|
|
|
|
|
confirmations = chainActive.Height() - blockindex->nHeight + 1; |
|
|
|
|
|
|
|
result.push_back(Pair("confirmations", confirmations)); |
|
|
|
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)); |
|
|
@ -242,7 +244,7 @@ Value getblock(const Array& params, bool fHelp) |
|
|
|
"\nResult (for verbose = true):\n" |
|
|
|
"\nResult (for verbose = true):\n" |
|
|
|
"{\n" |
|
|
|
"{\n" |
|
|
|
" \"hash\" : \"hash\", (string) the block hash (same as provided)\n" |
|
|
|
" \"hash\" : \"hash\", (string) the block hash (same as provided)\n" |
|
|
|
" \"confirmations\" : n, (numeric) The number of confirmations\n" |
|
|
|
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" |
|
|
|
" \"size\" : n, (numeric) The block size\n" |
|
|
|
" \"size\" : n, (numeric) The block size\n" |
|
|
|
" \"height\" : n, (numeric) The block height or index\n" |
|
|
|
" \"height\" : n, (numeric) The block height or index\n" |
|
|
|
" \"version\" : n, (numeric) The block version\n" |
|
|
|
" \"version\" : n, (numeric) The block version\n" |
|
|
|