Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 1) { | ||||
" \"height\" : { (int) Block height\n" | " \"height\" : { (int) Block height\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("waitfornewblock", "1000") + | HelpExampleCli("waitfornewblock", "1000") + | ||||
HelpExampleRpc("waitfornewblock", "1000")); | HelpExampleRpc("waitfornewblock", "1000")); | ||||
} | } | ||||
int timeout = 0; | int timeout = 0; | ||||
if (request.params.size() > 0) { | if (!request.params[0].isNull()) { | ||||
timeout = request.params[0].get_int(); | timeout = request.params[0].get_int(); | ||||
} | } | ||||
CUpdatedBlock block; | CUpdatedBlock block; | ||||
{ | { | ||||
WAIT_LOCK(cs_blockchange, lock); | WAIT_LOCK(cs_blockchange, lock); | ||||
block = latestblock; | block = latestblock; | ||||
if (timeout) { | if (timeout) { | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"570b24c9ed7b4a8c619eb02596f8862\", " | "570b24c9ed7b4a8c619eb02596f8862\", " | ||||
"1000")); | "1000")); | ||||
} | } | ||||
int timeout = 0; | int timeout = 0; | ||||
uint256 hash = uint256S(request.params[0].get_str()); | uint256 hash = uint256S(request.params[0].get_str()); | ||||
if (request.params.size() > 1) { | 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); | ||||
if (timeout) { | if (timeout) { | ||||
cond_blockchange.wait_for( | cond_blockchange.wait_for( | ||||
Show All 37 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
HelpExampleCli("waitforblockheight", "\"100\", 1000") + | HelpExampleCli("waitforblockheight", "\"100\", 1000") + | ||||
HelpExampleRpc("waitforblockheight", "\"100\", 1000")); | HelpExampleRpc("waitforblockheight", "\"100\", 1000")); | ||||
} | } | ||||
int timeout = 0; | int timeout = 0; | ||||
int height = request.params[0].get_int(); | int height = request.params[0].get_int(); | ||||
if (request.params.size() > 1) { | 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); | ||||
if (timeout) { | if (timeout) { | ||||
cond_blockchange.wait_for( | cond_blockchange.wait_for( | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 1) { | ||||
" }, ...\n" | " }, ...\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getrawmempool", "true") + | HelpExampleCli("getrawmempool", "true") + | ||||
HelpExampleRpc("getrawmempool", "true")); | HelpExampleRpc("getrawmempool", "true")); | ||||
} | } | ||||
bool fVerbose = false; | bool fVerbose = false; | ||||
if (request.params.size() > 0) { | if (!request.params[0].isNull()) { | ||||
fVerbose = request.params[0].get_bool(); | fVerbose = request.params[0].get_bool(); | ||||
} | } | ||||
return mempoolToJSON(fVerbose); | return mempoolToJSON(fVerbose); | ||||
} | } | ||||
UniValue getmempoolancestors(const Config &config, | UniValue getmempoolancestors(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
Show All 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
" }, ...\n" | " }, ...\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getmempoolancestors", "\"mytxid\"") + | HelpExampleCli("getmempoolancestors", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempoolancestors", "\"mytxid\"")); | HelpExampleRpc("getmempoolancestors", "\"mytxid\"")); | ||||
} | } | ||||
bool fVerbose = false; | bool fVerbose = false; | ||||
if (request.params.size() > 1) { | if (!request.params[1].isNull()) { | ||||
fVerbose = request.params[1].get_bool(); | fVerbose = request.params[1].get_bool(); | ||||
} | } | ||||
uint256 hash = ParseHashV(request.params[0], "parameter 1"); | uint256 hash = ParseHashV(request.params[0], "parameter 1"); | ||||
LOCK(g_mempool.cs); | LOCK(g_mempool.cs); | ||||
CTxMemPool::txiter it = g_mempool.mapTx.find(hash); | CTxMemPool::txiter it = g_mempool.mapTx.find(hash); | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
" }, ...\n" | " }, ...\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getmempooldescendants", "\"mytxid\"") + | HelpExampleCli("getmempooldescendants", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempooldescendants", "\"mytxid\"")); | HelpExampleRpc("getmempooldescendants", "\"mytxid\"")); | ||||
} | } | ||||
bool fVerbose = false; | bool fVerbose = false; | ||||
if (request.params.size() > 1) fVerbose = request.params[1].get_bool(); | if (!request.params[1].isNull()) { | ||||
fVerbose = request.params[1].get_bool(); | |||||
} | |||||
uint256 hash = ParseHashV(request.params[0], "parameter 1"); | uint256 hash = ParseHashV(request.params[0], "parameter 1"); | ||||
LOCK(g_mempool.cs); | LOCK(g_mempool.cs); | ||||
CTxMemPool::txiter it = g_mempool.mapTx.find(hash); | CTxMemPool::txiter it = g_mempool.mapTx.find(hash); | ||||
if (it == g_mempool.mapTx.end()) { | if (it == g_mempool.mapTx.end()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | UniValue getblockheader(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
uint256 hash(uint256S(strHash)); | uint256 hash(uint256S(strHash)); | ||||
bool fVerbose = true; | bool fVerbose = true; | ||||
if (request.params.size() > 1) { | if (!request.params[1].isNull()) { | ||||
fVerbose = request.params[1].get_bool(); | fVerbose = request.params[1].get_bool(); | ||||
} | } | ||||
if (mapBlockIndex.count(hash) == 0) { | if (mapBlockIndex.count(hash) == 0) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
CBlockIndex *pblockindex = mapBlockIndex[hash]; | CBlockIndex *pblockindex = mapBlockIndex[hash]; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | UniValue getblock(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
uint256 hash(uint256S(strHash)); | uint256 hash(uint256S(strHash)); | ||||
int verbosity = 1; | int verbosity = 1; | ||||
if (request.params.size() > 1) { | 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; | ||||
} | } | ||||
} | } | ||||
if (mapBlockIndex.count(hash) == 0) { | if (mapBlockIndex.count(hash) == 0) { | ||||
▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | UniValue gettxout(const Config &config, const JSONRPCRequest &request) { | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
uint256 hash(uint256S(strHash)); | uint256 hash(uint256S(strHash)); | ||||
int n = request.params[1].get_int(); | int n = request.params[1].get_int(); | ||||
COutPoint out(hash, n); | COutPoint out(hash, n); | ||||
bool fMempool = true; | bool fMempool = true; | ||||
if (request.params.size() > 2) { | if (!request.params[2].isNull()) { | ||||
fMempool = request.params[2].get_bool(); | fMempool = request.params[2].get_bool(); | ||||
} | } | ||||
Coin coin; | Coin coin; | ||||
if (fMempool) { | if (fMempool) { | ||||
LOCK(g_mempool.cs); | LOCK(g_mempool.cs); | ||||
CCoinsViewMemPool view(pcoinsTip.get(), g_mempool); | CCoinsViewMemPool view(pcoinsTip.get(), g_mempool); | ||||
if (!view.GetCoin(out, coin) || g_mempool.isSpent(out)) { | if (!view.GetCoin(out, coin) || g_mempool.isSpent(out)) { | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 2) { | ||||
"true|false (boolean) Verified or not\n" | "true|false (boolean) Verified or not\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("verifychain", "") + | HelpExampleCli("verifychain", "") + | ||||
HelpExampleRpc("verifychain", "")); | HelpExampleRpc("verifychain", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (request.params.size() > 0) { | if (!request.params[0].isNull()) { | ||||
nCheckLevel = request.params[0].get_int(); | nCheckLevel = request.params[0].get_int(); | ||||
} | } | ||||
if (request.params.size() > 1) { | if (!request.params[1].isNull()) { | ||||
nCheckDepth = request.params[1].get_int(); | nCheckDepth = request.params[1].get_int(); | ||||
} | } | ||||
return CVerifyDB().VerifyDB(config, pcoinsTip.get(), nCheckLevel, | return CVerifyDB().VerifyDB(config, pcoinsTip.get(), nCheckLevel, | ||||
nCheckDepth); | nCheckDepth); | ||||
} | } | ||||
/** Implementation of IsSuperMajority with better feedback */ | /** Implementation of IsSuperMajority with better feedback */ | ||||
▲ Show 20 Lines • Show All 665 Lines • Show Last 20 Lines |