// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#include "amount.h"
#include "chain.h"
#include "base58.h"
#include "consensus/validation.h"
#include "cc/eval.h"
+#include "key_io.h"
#include "main.h"
#include "primitives/transaction.h"
#include "rpc/server.h"
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex()));
+ result.push_back(Pair("chainstake", blockindex->chainPower.chainStake.GetHex()));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex()));
+ result.push_back(Pair("chainstake", blockindex->chainPower.chainStake.GetHex()));
result.push_back(Pair("anchor", blockindex->hashFinalSproutRoot.GetHex()));
result.push_back(Pair("blocktype", block.IsVerusPOSBlock() ? "minted" : "mined"));
UniValue getblockdeltas(const UniValue& params, bool fHelp)
{
+ std::string enableArg = "insightexplorer";
+ bool enabled = fExperimentalMode && fInsightExplorer;
+ std::string disabledMsg = "";
+ if (!enabled) {
+ disabledMsg = experimentalDisabledHelpMsg("getblockdeltas", enableArg);
+ }
if (fHelp || params.size() != 1)
- throw runtime_error("");
+ throw runtime_error(
+ "getblockdeltas \"blockhash\"\n"
+ "\nReturns information about the given block and its transactions.\n"
+ + disabledMsg +
+ "\nArguments:\n"
+ "1. \"hash\" (string, required) The block hash\n"
+ "\nResult:\n"
+ "{\n"
+ " \"hash\": \"hash\", (string) block ID\n"
+ " \"confirmations\": n, (numeric) number of confirmations\n"
+ " \"size\": n, (numeric) block size in bytes\n"
+ " \"height\": n, (numeric) block height\n"
+ " \"version\": n, (numeric) block version (e.g. 4)\n"
+ " \"merkleroot\": \"hash\", (hexstring) block Merkle root\n"
+ " \"deltas\": [\n"
+ " {\n"
+ " \"txid\": \"hash\", (hexstring) transaction ID\n"
+ " \"index\": n, (numeric) The offset of the tx in the block\n"
+ " \"inputs\": [ (array of json objects)\n"
+ " {\n"
+ " \"address\": \"taddr\", (string) transparent address\n"
+ " \"satoshis\": n, (numeric) negative of spend amount\n"
+ " \"index\": n, (numeric) vin index\n"
+ " \"prevtxid\": \"hash\", (string) source utxo tx ID\n"
+ " \"prevout\": n (numeric) source utxo index\n"
+ " }, ...\n"
+ " ],\n"
+ " \"outputs\": [ (array of json objects)\n"
+ " {\n"
+ " \"address\": \"taddr\", (string) transparent address\n"
+ " \"satoshis\": n, (numeric) amount\n"
+ " \"index\": n (numeric) vout index\n"
+ " }, ...\n"
+ " ]\n"
+ " }, ...\n"
+ " ],\n"
+ " \"time\" : n, (numeric) The block version\n"
+ " \"mediantime\": n, (numeric) The most recent blocks' ave time\n"
+ " \"nonce\" : \"nonce\", (hex string) The nonce\n"
+ " \"bits\" : \"1d00ffff\", (hex string) The bits\n"
+ " \"difficulty\": n, (numeric) the current difficulty\n"
+ " \"chainwork\": \"xxxx\" (hex string) total amount of work in active chain\n"
+ " \"previousblockhash\" : \"hash\",(hex string) The hash of the previous block\n"
+ " \"nextblockhash\" : \"hash\" (hex string) The hash of the next block\n"
+ "}\n"
+ "\nExamples:\n"
+ + HelpExampleCli("getblockdeltas", "00227e566682aebd6a7a5b772c96d7a999cadaebeaf1ce96f4191a3aad58b00b")
+ + HelpExampleRpc("getblockdeltas", "\"00227e566682aebd6a7a5b772c96d7a999cadaebeaf1ce96f4191a3aad58b00b\"")
+ );
+
+ if (!enabled) {
+ throw JSONRPCError(RPC_MISC_ERROR, "Error: getblockdeltas is disabled. "
+ "Run './verus help getblockdeltas' for instructions on how to enable this feature.");
+ }
std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
- if(!ReadBlockFromDisk(block, pblockindex,1))
+ if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus(), 1))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
return blockToDeltasJSON(block, pblockindex);
result.push_back(it->first.GetHex());
}
}
-
return result;
}
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
- if(!ReadBlockFromDisk(block, pblockindex,1))
+ if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus(), 1))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
if (verbosity == 0)
if (params.size() > 1)
nCheckDepth = params[1].get_int();
- return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
+ return CVerifyDB().VerifyDB(Params(), pcoinsTip, nCheckLevel, nCheckDepth);
}
/** Implementation of IsSuperMajority with better feedback */
}
}
+
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
+ " \"size_on_disk\": xxxxxx, (numeric) the estimated size of the block and undo files on disk\n"
" \"commitments\": xxxxxx, (numeric) the current number of note commitments in the commitment tree\n"
" \"softforks\": [ (array) status of softforks in progress\n"
" {\n"
obj.push_back(Pair("chainstake", chainActive.LastTip()->chainPower.chainStake.GetHex()));
}
obj.push_back(Pair("pruned", fPruneMode));
+ obj.push_back(Pair("size_on_disk", CalculateCurrentUsage()));
SproutMerkleTree tree;
pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree);
ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize()));
ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage()));
+ if (Params().NetworkIDString() == "regtest") {
+ ret.push_back(Pair("fullyNotified", mempool.IsFullyNotified()));
+ }
+
return ret;
}
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pblockindex = mapBlockIndex[hash];
- InvalidateBlock(state, pblockindex);
+ InvalidateBlock(state, Params(), pblockindex);
}
if (state.IsValid()) {
- ActivateBestChain(state);
+ ActivateBestChain(state, Params());
}
if (!state.IsValid()) {
}
if (state.IsValid()) {
- ActivateBestChain(state);
+ ActivateBestChain(state, Params());
}
if (!state.IsValid()) {
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
{ "blockchain", "verifychain", &verifychain, true },
+ // insightexplorer
+ { "blockchain", "getblockdeltas", &getblockdeltas, false },
+ { "blockchain", "getblockhashes", &getblockhashes, true },
+
/* Not shown in help */
{ "hidden", "invalidateblock", &invalidateblock, true },
{ "hidden", "reconsiderblock", &reconsiderblock, true },