Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | UniValue blockheaderToJSON(const CBlockIndex *tip, | ||||
result.pushKV("versionHex", strprintf("%08x", blockindex->nVersion)); | result.pushKV("versionHex", strprintf("%08x", blockindex->nVersion)); | ||||
result.pushKV("merkleroot", blockindex->hashMerkleRoot.GetHex()); | result.pushKV("merkleroot", blockindex->hashMerkleRoot.GetHex()); | ||||
result.pushKV("time", int64_t(blockindex->nTime)); | result.pushKV("time", int64_t(blockindex->nTime)); | ||||
result.pushKV("mediantime", int64_t(blockindex->GetMedianTimePast())); | result.pushKV("mediantime", int64_t(blockindex->GetMedianTimePast())); | ||||
result.pushKV("nonce", uint64_t(blockindex->nNonce)); | result.pushKV("nonce", uint64_t(blockindex->nNonce)); | ||||
result.pushKV("bits", strprintf("%08x", blockindex->nBits)); | result.pushKV("bits", strprintf("%08x", blockindex->nBits)); | ||||
result.pushKV("difficulty", GetDifficulty(blockindex)); | result.pushKV("difficulty", GetDifficulty(blockindex)); | ||||
result.pushKV("chainwork", blockindex->nChainWork.GetHex()); | result.pushKV("chainwork", blockindex->nChainWork.GetHex()); | ||||
result.pushKV("nTx", uint64_t(blockindex->nTx)); | |||||
if (blockindex->pprev) { | if (blockindex->pprev) { | ||||
result.pushKV("previousblockhash", | result.pushKV("previousblockhash", | ||||
blockindex->pprev->GetBlockHash().GetHex()); | blockindex->pprev->GetBlockHash().GetHex()); | ||||
} | } | ||||
if (pnext) { | if (pnext) { | ||||
result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); | result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); | ||||
} | } | ||||
Show All 24 Lines | UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, | ||||
} | } | ||||
result.pushKV("tx", txs); | result.pushKV("tx", txs); | ||||
result.pushKV("time", block.GetBlockTime()); | result.pushKV("time", block.GetBlockTime()); | ||||
result.pushKV("mediantime", int64_t(blockindex->GetMedianTimePast())); | result.pushKV("mediantime", int64_t(blockindex->GetMedianTimePast())); | ||||
result.pushKV("nonce", uint64_t(block.nNonce)); | result.pushKV("nonce", uint64_t(block.nNonce)); | ||||
result.pushKV("bits", strprintf("%08x", block.nBits)); | result.pushKV("bits", strprintf("%08x", block.nBits)); | ||||
result.pushKV("difficulty", GetDifficulty(blockindex)); | result.pushKV("difficulty", GetDifficulty(blockindex)); | ||||
result.pushKV("chainwork", blockindex->nChainWork.GetHex()); | result.pushKV("chainwork", blockindex->nChainWork.GetHex()); | ||||
result.pushKV("nTx", uint64_t(blockindex->nTx)); | |||||
if (blockindex->pprev) { | if (blockindex->pprev) { | ||||
result.pushKV("previousblockhash", | result.pushKV("previousblockhash", | ||||
blockindex->pprev->GetBlockHash().GetHex()); | blockindex->pprev->GetBlockHash().GetHex()); | ||||
} | } | ||||
if (pnext) { | if (pnext) { | ||||
result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); | result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 650 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"since epoch (Jan 1 1970 GMT)\n" | "since epoch (Jan 1 1970 GMT)\n" | ||||
" \"mediantime\" : ttt, (numeric) The median block time in " | " \"mediantime\" : ttt, (numeric) The median block time in " | ||||
"seconds since epoch (Jan 1 1970 GMT)\n" | "seconds since epoch (Jan 1 1970 GMT)\n" | ||||
" \"nonce\" : n, (numeric) The nonce\n" | " \"nonce\" : n, (numeric) The nonce\n" | ||||
" \"bits\" : \"1d00ffff\", (string) The bits\n" | " \"bits\" : \"1d00ffff\", (string) The bits\n" | ||||
" \"difficulty\" : x.xxx, (numeric) The difficulty\n" | " \"difficulty\" : x.xxx, (numeric) The difficulty\n" | ||||
" \"chainwork\" : \"0000...1f3\" (string) Expected number of " | " \"chainwork\" : \"0000...1f3\" (string) Expected number of " | ||||
"hashes required to produce the current chain (in hex)\n" | "hashes required to produce the current chain (in hex)\n" | ||||
" \"nTx\" : n, (numeric) The number of transactions " | |||||
"in the block.\n" | |||||
" \"previousblockhash\" : \"hash\", (string) The hash of the " | " \"previousblockhash\" : \"hash\", (string) The hash of the " | ||||
"previous block\n" | "previous block\n" | ||||
" \"nextblockhash\" : \"hash\", (string) The hash of the " | " \"nextblockhash\" : \"hash\", (string) The hash of the " | ||||
"next block\n" | "next block\n" | ||||
"}\n" | "}\n" | ||||
"\nResult (for verbose=false):\n" | "\nResult (for verbose=false):\n" | ||||
"\"data\" (string) A string that is serialized, " | "\"data\" (string) A string that is serialized, " | ||||
"hex-encoded data for block 'hash'.\n" | "hex-encoded data for block 'hash'.\n" | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"since epoch (Jan 1 1970 GMT)\n" | "since epoch (Jan 1 1970 GMT)\n" | ||||
" \"mediantime\" : ttt, (numeric) The median block time in " | " \"mediantime\" : ttt, (numeric) The median block time in " | ||||
"seconds since epoch (Jan 1 1970 GMT)\n" | "seconds since epoch (Jan 1 1970 GMT)\n" | ||||
" \"nonce\" : n, (numeric) The nonce\n" | " \"nonce\" : n, (numeric) The nonce\n" | ||||
" \"bits\" : \"1d00ffff\", (string) The bits\n" | " \"bits\" : \"1d00ffff\", (string) The bits\n" | ||||
" \"difficulty\" : x.xxx, (numeric) The difficulty\n" | " \"difficulty\" : x.xxx, (numeric) The difficulty\n" | ||||
" \"chainwork\" : \"xxxx\", (string) Expected number of hashes " | " \"chainwork\" : \"xxxx\", (string) Expected number of hashes " | ||||
"required to produce the chain up to this block (in hex)\n" | "required to produce the chain up to this block (in hex)\n" | ||||
" \"nTx\" : n, (numeric) The number of transactions " | |||||
"in the block.\n" | |||||
" \"previousblockhash\" : \"hash\", (string) The hash of the " | " \"previousblockhash\" : \"hash\", (string) The hash of the " | ||||
"previous block\n" | "previous block\n" | ||||
" \"nextblockhash\" : \"hash\" (string) The hash of the " | " \"nextblockhash\" : \"hash\" (string) The hash of the " | ||||
"next block\n" | "next block\n" | ||||
"}\n" | "}\n" | ||||
"\nResult (for verbosity = 2):\n" | "\nResult (for verbosity = 2):\n" | ||||
"{\n" | "{\n" | ||||
" ..., Same output as verbosity = 1\n" | " ..., Same output as verbosity = 1\n" | ||||
▲ Show 20 Lines • Show All 1,615 Lines • Show Last 20 Lines |