Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"1000") + | "1000") + | ||||
HelpExampleRpc("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4" | HelpExampleRpc("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4" | ||||
"570b24c9ed7b4a8c619eb02596f8862\", " | "570b24c9ed7b4a8c619eb02596f8862\", " | ||||
"1000")); | "1000")); | ||||
} | } | ||||
int timeout = 0; | int timeout = 0; | ||||
uint256 hash = uint256S(request.params[0].get_str()); | BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
timeout = request.params[1].get_int(); | timeout = request.params[1].get_int(); | ||||
} | } | ||||
CUpdatedBlock block; | CUpdatedBlock block; | ||||
{ | { | ||||
WAIT_LOCK(cs_blockchange, lock); | WAIT_LOCK(cs_blockchange, lock); | ||||
▲ Show 20 Lines • Show All 509 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec3" | HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec3" | ||||
"7b049d214adbda81d7e2a3dd146f6ed09" | "7b049d214adbda81d7e2a3dd146f6ed09" | ||||
"\"") + | "\"") + | ||||
HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec3" | HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec3" | ||||
"7b049d214adbda81d7e2a3dd146f6ed09" | "7b049d214adbda81d7e2a3dd146f6ed09" | ||||
"\"")); | "\"")); | ||||
} | } | ||||
std::string strHash = request.params[0].get_str(); | BlockHash hash(ParseHashV(request.params[0], "hash")); | ||||
BlockHash hash(uint256S(strHash)); | |||||
bool fVerbose = true; | bool fVerbose = true; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
fVerbose = request.params[1].get_bool(); | fVerbose = request.params[1].get_bool(); | ||||
} | } | ||||
const CBlockIndex *pblockindex; | const CBlockIndex *pblockindex; | ||||
const CBlockIndex *tip; | const CBlockIndex *tip; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d" | HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d" | ||||
"214adbda81d7e2a3dd146f6ed09\"") + | "214adbda81d7e2a3dd146f6ed09\"") + | ||||
HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d" | HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d" | ||||
"214adbda81d7e2a3dd146f6ed09\"")); | "214adbda81d7e2a3dd146f6ed09\"")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
std::string strHash = request.params[0].get_str(); | BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
BlockHash hash(uint256S(strHash)); | |||||
int verbosity = 1; | int verbosity = 1; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
if (request.params[1].isNum()) { | if (request.params[1].isNum()) { | ||||
verbosity = request.params[1].get_int(); | verbosity = request.params[1].get_int(); | ||||
} else { | } else { | ||||
verbosity = request.params[1].get_bool() ? 1 : 0; | verbosity = request.params[1].get_bool() ? 1 : 0; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
"\nAs a json rpc call\n" + | "\nAs a json rpc call\n" + | ||||
HelpExampleRpc("gettxout", "\"txid\", 1")); | HelpExampleRpc("gettxout", "\"txid\", 1")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
std::string strTxId = request.params[0].get_str(); | TxId txid(ParseHashV(request.params[0], "txid")); | ||||
TxId txid(uint256S(strTxId)); | |||||
int n = request.params[1].get_int(); | int n = request.params[1].get_int(); | ||||
COutPoint out(txid, n); | COutPoint out(txid, n); | ||||
bool fMempool = true; | bool fMempool = true; | ||||
if (!request.params[2].isNull()) { | if (!request.params[2].isNull()) { | ||||
fMempool = request.params[2].get_bool(); | fMempool = request.params[2].get_bool(); | ||||
} | } | ||||
Coin coin; | Coin coin; | ||||
▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"1. \"blockhash\" (string, required) the hash of the block to " | "1. \"blockhash\" (string, required) the hash of the block to " | ||||
"mark as precious\n" | "mark as precious\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("preciousblock", "\"blockhash\"") + | HelpExampleCli("preciousblock", "\"blockhash\"") + | ||||
HelpExampleRpc("preciousblock", "\"blockhash\"")); | HelpExampleRpc("preciousblock", "\"blockhash\"")); | ||||
} | } | ||||
std::string strHash = request.params[0].get_str(); | BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
BlockHash hash(uint256S(strHash)); | |||||
CBlockIndex *pblockindex; | CBlockIndex *pblockindex; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
pblockindex = LookupBlockIndex(hash); | pblockindex = LookupBlockIndex(hash); | ||||
if (!pblockindex) { | if (!pblockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"1. \"blockhash\" (string, required) the hash of " | "1. \"blockhash\" (string, required) the hash of " | ||||
"the block to mark as invalid\n" | "the block to mark as invalid\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("invalidateblock", "\"blockhash\"") + | HelpExampleCli("invalidateblock", "\"blockhash\"") + | ||||
HelpExampleRpc("invalidateblock", "\"blockhash\"")); | HelpExampleRpc("invalidateblock", "\"blockhash\"")); | ||||
} | } | ||||
const std::string strHash = request.params[0].get_str(); | const BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
const BlockHash hash(uint256S(strHash)); | |||||
CValidationState state; | CValidationState state; | ||||
CBlockIndex *pblockindex; | CBlockIndex *pblockindex; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
pblockindex = LookupBlockIndex(hash); | pblockindex = LookupBlockIndex(hash); | ||||
if (!pblockindex) { | if (!pblockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"1. \"blockhash\" (string, required) the hash of the block to " | "1. \"blockhash\" (string, required) the hash of the block to " | ||||
"reconsider\n" | "reconsider\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("reconsiderblock", "\"blockhash\"") + | HelpExampleCli("reconsiderblock", "\"blockhash\"") + | ||||
HelpExampleRpc("reconsiderblock", "\"blockhash\"")); | HelpExampleRpc("reconsiderblock", "\"blockhash\"")); | ||||
} | } | ||||
const std::string strHash = request.params[0].get_str(); | const BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
const BlockHash hash(uint256S(strHash)); | |||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CBlockIndex *pblockindex = LookupBlockIndex(hash); | CBlockIndex *pblockindex = LookupBlockIndex(hash); | ||||
if (!pblockindex) { | if (!pblockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | static UniValue getchaintxstats(const Config &config, | ||||
// By default: 1 month | // By default: 1 month | ||||
int blockcount = 30 * 24 * 60 * 60 / | int blockcount = 30 * 24 * 60 * 60 / | ||||
config.GetChainParams().GetConsensus().nPowTargetSpacing; | config.GetChainParams().GetConsensus().nPowTargetSpacing; | ||||
if (request.params[1].isNull()) { | if (request.params[1].isNull()) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
pindex = chainActive.Tip(); | pindex = chainActive.Tip(); | ||||
} else { | } else { | ||||
BlockHash hash(uint256S(request.params[1].get_str())); | BlockHash hash(ParseHashV(request.params[1], "blockhash")); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
pindex = LookupBlockIndex(hash); | pindex = LookupBlockIndex(hash); | ||||
if (!pindex) { | if (!pindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
if (!chainActive.Contains(pindex)) { | if (!chainActive.Contains(pindex)) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Block is not in main chain"); | "Block is not in main chain"); | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | if (request.params[0].isNum()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
strprintf("Target block height %d after current tip %d", height, | strprintf("Target block height %d after current tip %d", height, | ||||
current_tip)); | current_tip)); | ||||
} | } | ||||
pindex = chainActive[height]; | pindex = chainActive[height]; | ||||
} else { | } else { | ||||
const std::string strHash = request.params[0].get_str(); | const BlockHash hash(ParseHashV(request.params[0], "hash_or_height")); | ||||
const BlockHash hash(uint256S(strHash)); | |||||
pindex = LookupBlockIndex(hash); | pindex = LookupBlockIndex(hash); | ||||
if (!pindex) { | if (!pindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
if (!chainActive.Contains(pindex)) { | if (!chainActive.Contains(pindex)) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
strprintf("Block is not in chain %s", | strprintf("Block is not in chain %s", | ||||
Params().NetworkIDString())); | Params().NetworkIDString())); | ||||
▲ Show 20 Lines • Show All 523 Lines • Show Last 20 Lines |