|
|
@ -395,12 +395,15 @@ UniValue getblock(const UniValue& params, bool fHelp) |
|
|
|
if (fHelp || params.size() < 1 || params.size() > 2) |
|
|
|
throw runtime_error( |
|
|
|
"getblock \"hash|height\" ( verbose )\n" |
|
|
|
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash|height'.\n" |
|
|
|
"If verbose is true, returns an Object with information about block <hash|height>.\n" |
|
|
|
"\nIf verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.\n" |
|
|
|
"If verbosity is 1, returns an Object with information about block <hash>.\n" |
|
|
|
"If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n" |
|
|
|
"\nArguments:\n" |
|
|
|
"1. \"hash|height\" (string, required) The block hash or height\n" |
|
|
|
"2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n" |
|
|
|
"\nResult (for verbose = true):\n" |
|
|
|
"1. \"blockhash\" (string, required) The block hash\n" |
|
|
|
"2. verbosity (numeric, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data\n" |
|
|
|
"\nResult (for verbosity = 0):\n" |
|
|
|
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" |
|
|
|
"\nResult (for verbosity = 1):\n" |
|
|
|
"{\n" |
|
|
|
" \"hash\" : \"hash\", (string) the block hash (same as provided hash)\n" |
|
|
|
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" |
|
|
@ -419,8 +422,14 @@ UniValue getblock(const UniValue& params, bool fHelp) |
|
|
|
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" |
|
|
|
" \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" |
|
|
|
"}\n" |
|
|
|
"\nResult (for verbose=false):\n" |
|
|
|
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" |
|
|
|
"\nResult (for verbosity = 2):\n" |
|
|
|
"{\n" |
|
|
|
" ..., Same output as verbosity = 1.\n" |
|
|
|
" \"tx\" : [ (array of Objects) The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result.\n" |
|
|
|
" ,...\n" |
|
|
|
" ],\n" |
|
|
|
" ,... Same output as verbosity = 1.\n" |
|
|
|
"}\n" |
|
|
|
"\nExamples:\n" |
|
|
|
+ HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") |
|
|
|
+ HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") |
|
|
@ -456,9 +465,13 @@ UniValue getblock(const UniValue& params, bool fHelp) |
|
|
|
|
|
|
|
uint256 hash(uint256S(strHash)); |
|
|
|
|
|
|
|
bool fVerbose = true; |
|
|
|
if (params.size() > 1) |
|
|
|
fVerbose = params[1].get_bool(); |
|
|
|
int verbosity = 1; |
|
|
|
if (params.size() > 1) { |
|
|
|
if(params[1].isNum()) |
|
|
|
verbosity = params[1].get_int(); |
|
|
|
else |
|
|
|
verbosity = params[1].get_bool() ? 1 : 0; |
|
|
|
} |
|
|
|
|
|
|
|
if (mapBlockIndex.count(hash) == 0) |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
|
|
@ -472,7 +485,7 @@ UniValue getblock(const UniValue& params, bool fHelp) |
|
|
|
if(!ReadBlockFromDisk(block, pblockindex)) |
|
|
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); |
|
|
|
|
|
|
|
if (!fVerbose) |
|
|
|
if (verbosity <= 0) |
|
|
|
{ |
|
|
|
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
ssBlock << block; |
|
|
@ -480,7 +493,7 @@ UniValue getblock(const UniValue& params, bool fHelp) |
|
|
|
return strHex; |
|
|
|
} |
|
|
|
|
|
|
|
return blockToJSON(block, pblockindex); |
|
|
|
return blockToJSON(block, pblockindex, verbosity >= 2); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gettxoutsetinfo(const UniValue& params, bool fHelp) |
|
|
|