Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | |||||
static UniValue getbestblockhash(const Config &config, | static UniValue getbestblockhash(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getbestblockhash\n" | "getbestblockhash\n" | ||||
"\nReturns the hash of the best (tip) block in the " | "\nReturns the hash of the best (tip) block in the " | ||||
"longest blockchain.\n" | "longest blockchain.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hex\" (string) the block hash hex encoded\n" | "\"hex\" (string) the block hash hex-encoded\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getbestblockhash", "") + | HelpExampleCli("getbestblockhash", "") + | ||||
HelpExampleRpc("getbestblockhash", "")); | HelpExampleRpc("getbestblockhash", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
return ::ChainActive().Tip()->GetBlockHash().GetHex(); | return ::ChainActive().Tip()->GetBlockHash().GetHex(); | ||||
} | } | ||||
UniValue getfinalizedblockhash(const Config &config, | UniValue getfinalizedblockhash(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getfinalizedblockhash\n" | "getfinalizedblockhash\n" | ||||
"\nReturns the hash of the currently finalized block\n" | "\nReturns the hash of the currently finalized block\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hex\" (string) the block hash hex encoded\n"); | "\"hex\" (string) the block hash hex-encoded\n"); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CBlockIndex *blockIndexFinalized = GetFinalizedBlock(); | const CBlockIndex *blockIndexFinalized = GetFinalizedBlock(); | ||||
if (blockIndexFinalized) { | if (blockIndexFinalized) { | ||||
return blockIndexFinalized->GetBlockHash().GetHex(); | return blockIndexFinalized->GetBlockHash().GetHex(); | ||||
} | } | ||||
return UniValue(UniValue::VSTR); | return UniValue(UniValue::VSTR); | ||||
▲ Show 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | static UniValue getrawmempool(const Config &config, | ||||
return MempoolToJSON(::g_mempool, fVerbose); | return MempoolToJSON(::g_mempool, fVerbose); | ||||
} | } | ||||
static UniValue getmempoolancestors(const Config &config, | static UniValue getmempoolancestors(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getmempoolancestors txid (verbose)\n" | "getmempoolancestors txid ( verbose )\n" | ||||
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n" | "\nIf txid is in the mempool, returns all in-mempool ancestors.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"txid\" (string, required) The transaction id " | "1. \"txid\" (string, required) The transaction id " | ||||
"(must be in mempool)\n" | "(must be in mempool)\n" | ||||
"2. verbose (boolean, optional, default=false) " | "2. verbose (boolean, optional, default=false) " | ||||
"True for a json object, false for array of transaction ids\n" | "True for a json object, false for array of transaction ids\n" | ||||
"\nResult (for verbose=false):\n" | "\nResult (for verbose = false):\n" | ||||
"[ (json array of strings)\n" | "[ (json array of strings)\n" | ||||
" \"transactionid\" (string) The transaction id of an " | " \"transactionid\" (string) The transaction id of an " | ||||
"in-mempool ancestor transaction\n" | "in-mempool ancestor transaction\n" | ||||
" ,...\n" | " ,...\n" | ||||
"]\n" | "]\n" | ||||
"\nResult (for verbose=true):\n" | "\nResult (for verbose = true):\n" | ||||
"{ (json object)\n" | "{ (json object)\n" | ||||
" \"transactionid\" : { (json object)\n" + | " \"transactionid\" : { (json object)\n" + | ||||
EntryDescriptionString() + | EntryDescriptionString() + | ||||
" }, ...\n" | " }, ...\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getmempoolancestors", "\"mytxid\"") + | HelpExampleCli("getmempoolancestors", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempoolancestors", "\"mytxid\"")); | HelpExampleRpc("getmempoolancestors", "\"mytxid\"")); | ||||
Show All 40 Lines | static UniValue getmempoolancestors(const Config &config, | ||||
} | } | ||||
} | } | ||||
static UniValue getmempooldescendants(const Config &config, | static UniValue getmempooldescendants(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getmempooldescendants txid (verbose)\n" | "getmempooldescendants txid ( verbose )\n" | ||||
"\nIf txid is in the mempool, returns all in-mempool descendants.\n" | "\nIf txid is in the mempool, returns all in-mempool descendants.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"txid\" (string, required) The transaction id " | "1. \"txid\" (string, required) The transaction id " | ||||
"(must be in mempool)\n" | "(must be in mempool)\n" | ||||
"2. verbose (boolean, optional, default=false) " | "2. verbose (boolean, optional, default=false) " | ||||
"True for a json object, false for array of transaction ids\n" | "True for a json object, false for array of transaction ids\n" | ||||
"\nResult (for verbose=false):\n" | "\nResult (for verbose = false):\n" | ||||
"[ (json array of strings)\n" | "[ (json array of strings)\n" | ||||
" \"transactionid\" (string) The transaction id of an " | " \"transactionid\" (string) The transaction id of an " | ||||
"in-mempool descendant transaction\n" | "in-mempool descendant transaction\n" | ||||
" ,...\n" | " ,...\n" | ||||
"]\n" | "]\n" | ||||
"\nResult (for verbose=true):\n" | "\nResult (for verbose = true):\n" | ||||
"{ (json object)\n" | "{ (json object)\n" | ||||
" \"transactionid\" : { (json object)\n" + | " \"transactionid\" : { (json object)\n" + | ||||
EntryDescriptionString() + | EntryDescriptionString() + | ||||
" }, ...\n" | " }, ...\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getmempooldescendants", "\"mytxid\"") + | HelpExampleCli("getmempooldescendants", "\"mytxid\"") + | ||||
HelpExampleRpc("getmempooldescendants", "\"mytxid\"")); | HelpExampleRpc("getmempooldescendants", "\"mytxid\"")); | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"getblockheader \"blockhash\" ( verbose )\n" | "getblockheader \"blockhash\" ( verbose )\n" | ||||
"\nIf verbose is false, returns a string that is serialized, " | "\nIf verbose is false, returns a string that is serialized, " | ||||
"hex-encoded data for blockheader 'hash'.\n" | "hex-encoded data for blockheader 'hash'.\n" | ||||
"If verbose is true, returns an Object with information about " | "If verbose is true, returns an Object with information about " | ||||
"blockheader <hash>.\n" | "blockheader <hash>.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) The block hash\n" | "1. \"blockhash\" (string, required) The block hash\n" | ||||
"2. verbose (boolean, optional, default=true) true for a " | "2. verbose (boolean, optional, default=true) true for a " | ||||
"json object, false for the hex encoded data\n" | "json object, false for the hex-encoded data\n" | ||||
"\nResult (for verbose = true):\n" | "\nResult (for verbose = true):\n" | ||||
"{\n" | "{\n" | ||||
" \"hash\" : \"hash\", (string) the block hash (same as " | " \"hash\" : \"hash\", (string) the block hash (same as " | ||||
"provided)\n" | "provided)\n" | ||||
" \"confirmations\" : n, (numeric) The number of confirmations, " | " \"confirmations\" : n, (numeric) The number of confirmations, " | ||||
"or -1 if the block is not on the main chain\n" | "or -1 if the block is not on the main chain\n" | ||||
" \"height\" : n, (numeric) The block height or index\n" | " \"height\" : n, (numeric) The block height or index\n" | ||||
" \"version\" : n, (numeric) The block version\n" | " \"version\" : n, (numeric) The block version\n" | ||||
▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
" },\n" | " },\n" | ||||
" \"coinbase\" : true|false (boolean) Coinbase or not\n" | " \"coinbase\" : true|false (boolean) Coinbase or not\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nGet unspent transactions\n" + | "\nGet unspent transactions\n" + | ||||
HelpExampleCli("listunspent", "") + "\nView the details\n" + | HelpExampleCli("listunspent", "") + "\nView the details\n" + | ||||
HelpExampleCli("gettxout", "\"txid\" 1") + | HelpExampleCli("gettxout", "\"txid\" 1") + | ||||
"\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); | ||||
TxId txid(ParseHashV(request.params[0], "txid")); | TxId txid(ParseHashV(request.params[0], "txid")); | ||||
▲ Show 20 Lines • Show All 1,401 Lines • Show Last 20 Lines |