Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <rpc/server.h>
#include <base58.h>
#include <fs.h>
#include <init.h>
#include <random.h>
#include <sync.h>
#include <ui_interface.h>
#include <util.h>
#include <utilstrencodings.h>
#include <boost/bind.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <algorithm>
#include <memory>
#include <unordered_map>
Go to the source code of this file.
Classes | |
struct | CRPCSignals |
Functions | |
static std::string | rpcWarmupStatus ("RPC server started") |
void | RPCTypeCheck (const UniValue ¶ms, const std::list< UniValue::VType > &typesExpected, bool fAllowNull) |
Type-check arguments; throws JSONRPCError if wrong type given. More... | |
void | RPCTypeCheckArgument (const UniValue &value, UniValue::VType typeExpected) |
Type-check one argument; throws JSONRPCError if wrong type given. More... | |
void | RPCTypeCheckObj (const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict) |
CAmount | AmountFromValue (const UniValue &value) |
uint256 | ParseHashV (const UniValue &v, std::string strName) |
Utilities: convert hex-encoded Values (throws error if not hex). More... | |
uint256 | ParseHashO (const UniValue &o, std::string strKey) |
std::vector< unsigned char > | ParseHexV (const UniValue &v, std::string strName) |
std::vector< unsigned char > | ParseHexO (const UniValue &o, std::string strKey) |
int32_t | ParseInt32V (const UniValue &v, const std::string &strName) |
int64_t | ParseInt64V (const UniValue &v, const std::string &strName) |
double | ParseDoubleV (const UniValue &v, const std::string &strName) |
bool | ParseBoolV (const UniValue &v, const std::string &strName) |
UniValue | help (const JSONRPCRequest &jsonRequest) |
UniValue | stop (const JSONRPCRequest &jsonRequest) |
UniValue | uptime (const JSONRPCRequest &jsonRequest) |
bool | StartRPC () |
void | InterruptRPC () |
void | StopRPC () |
bool | IsRPCRunning () |
Query whether RPC is running. More... | |
void | SetRPCWarmupStatus (const std::string &newStatus) |
Set the RPC warmup status. More... | |
void | SetRPCWarmupFinished () |
bool | RPCIsInWarmup (std::string *outStatus) |
bool | IsDeprecatedRPCEnabled (const std::string &method) |
static UniValue | JSONRPCExecOne (JSONRPCRequest jreq, const UniValue &req) |
std::string | JSONRPCExecBatch (const JSONRPCRequest &jreq, const UniValue &vReq) |
static JSONRPCRequest | transformNamedArguments (const JSONRPCRequest &in, const std::vector< std::string > &argNames) |
Process named arguments into a vector of positional arguments, based on the passed-in specification for the RPC call's arguments. More... | |
std::string | HelpExampleCli (const std::string &methodname, const std::string &args) |
std::string | HelpExampleRpc (const std::string &methodname, const std::string &args) |
void | RPCSetTimerInterfaceIfUnset (RPCTimerInterface *iface) |
Set the factory function for timer, but only, if unset. More... | |
void | RPCSetTimerInterface (RPCTimerInterface *iface) |
Set the factory function for timers. More... | |
void | RPCUnsetTimerInterface (RPCTimerInterface *iface) |
Unset factory function for timers. More... | |
void | RPCRunLater (const std::string &name, std::function< void(void)> func, int64_t nSeconds) |
Run func nSeconds from now. More... | |
Variables | |
static bool | fRPCRunning = false |
static bool | fRPCInWarmup = true |
static CCriticalSection | cs_rpcWarmup |
static RPCTimerInterface * | timerInterface = nullptr |
static std::map< std::string, std::unique_ptr< RPCTimerBase > > | deadlineTimers |
static struct CRPCSignals | g_rpcSignals |
static const CRPCCommand | vRPCCommands [] |
Call Table. More... | |
CRPCTable | tableRPC |
Function Documentation
◆ AmountFromValue()
Definition at line 109 of file server.cpp.
References UniValue::getValStr(), UniValue::isNum(), UniValue::isStr(), JSONRPCError(), MoneyRange(), ParseFixedPoint(), and RPC_TYPE_ERROR.
◆ help()
UniValue help | ( | const JSONRPCRequest & | jsonRequest | ) |
Definition at line 263 of file server.cpp.
References JSONRPCRequest::fHelp, UniValue::get_str(), CRPCTable::help(), JSONRPCRequest::params, UniValue::size(), and tableRPC.
Referenced by BitcoinGUI::createMenuBar(), and main().
◆ HelpExampleCli()
std::string HelpExampleCli | ( | const std::string & | methodname, |
const std::string & | args | ||
) |
Definition at line 578 of file server.cpp.
Referenced by abandontransaction(), abortrescan(), addmultisigaddress(), addnode(), backupwallet(), bls_fromsecret_help(), bls_generate_help(), clearbanned(), combinerawtransaction(), createmultisig(), createrawtransaction(), debug(), decoderawtransaction(), decodescript(), disconnectnode(), dumphdinfo(), dumpprivkey(), dumpwallet(), encryptwallet(), estimatefee(), estimaterawfee(), estimatesmartfee(), fundrawtransaction(), getaccount(), getaccountaddress(), getaddednodeinfo(), getaddressbalance(), getaddressdeltas(), getaddressesbyaccount(), getaddressmempool(), getaddresstxids(), getaddressutxos(), getbalance(), getbestblockhash(), getbestchainlock(), getblock(), getblockchaininfo(), getblockcount(), getblockhash(), getblockhashes(), getblockheader(), getblockheaders(), getblockstats(), getblocktemplate(), getchaintips(), getchaintxstats(), getconnectioncount(), getdifficulty(), getgovernanceinfo(), getmemoryinfo(), getmempoolancestors(), getmempooldescendants(), getmempoolentry(), getmempoolinfo(), getmerkleblocks(), getmininginfo(), getnettotals(), getnetworkhashps(), getnetworkinfo(), getnewaddress(), getpeerinfo(), getprivatesendinfo(), getrawchangeaddress(), getrawmempool(), getrawtransaction(), getreceivedbyaccount(), getreceivedbyaddress(), getspecialtxes(), getspentinfo(), getsuperblockbudget(), gettransaction(), gettxout(), gettxoutproof(), gettxoutsetinfo(), getwalletinfo(), importaddress(), importelectrumwallet(), importmulti(), importprivkey(), importpubkey(), importwallet(), invalidateblock(), keypoolrefill(), listaccounts(), listaddressbalances(), listaddressgroupings(), listbanned(), listlockunspent(), listreceivedbyaccount(), listreceivedbyaddress(), listsinceblock(), listtransactions(), listunspent(), listwallets(), loadwallet(), lockunspent(), logging(), movecmd(), ping(), preciousblock(), prioritisetransaction(), protx_info_help(), pruneblockchain(), quorum_list_help(), reconsiderblock(), removeprunedfunds(), rescanblockchain(), savemempool(), sendfrom(), sendmany(), sendrawtransaction(), sendtoaddress(), setaccount(), setban(), setprivatesendamount(), setprivatesendrounds(), settxfee(), signmessage(), signmessagewithprivkey(), signrawtransaction(), spork(), submitblock(), uptime(), validateaddress(), verifychain(), verifymessage(), verifytxoutproof(), waitforblock(), waitforblockheight(), waitfornewblock(), walletlock(), walletpassphrase(), and walletpassphrasechange().
◆ HelpExampleRpc()
std::string HelpExampleRpc | ( | const std::string & | methodname, |
const std::string & | args | ||
) |
Definition at line 583 of file server.cpp.
References BaseParams(), gArgs, ArgsManager::GetArg(), and strprintf.
Referenced by abandontransaction(), abortrescan(), addmultisigaddress(), addnode(), backupwallet(), clearbanned(), createmultisig(), createrawtransaction(), debug(), decoderawtransaction(), decodescript(), disconnectnode(), dumphdinfo(), dumpprivkey(), dumpwallet(), encryptwallet(), getaccount(), getaccountaddress(), getaddednodeinfo(), getaddressbalance(), getaddressdeltas(), getaddressesbyaccount(), getaddressmempool(), getaddresstxids(), getaddressutxos(), getbalance(), getbestblockhash(), getbestchainlock(), getblock(), getblockchaininfo(), getblockcount(), getblockhash(), getblockhashes(), getblockheader(), getblockheaders(), getblockstats(), getblocktemplate(), getchaintips(), getchaintxstats(), getconnectioncount(), getdifficulty(), getgovernanceinfo(), getmemoryinfo(), getmempoolancestors(), getmempooldescendants(), getmempoolentry(), getmempoolinfo(), getmerkleblocks(), getmininginfo(), getnettotals(), getnetworkhashps(), getnetworkinfo(), getnewaddress(), getpeerinfo(), getprivatesendinfo(), getrawchangeaddress(), getrawmempool(), getrawtransaction(), getreceivedbyaccount(), getreceivedbyaddress(), getspecialtxes(), getspentinfo(), getsuperblockbudget(), gettransaction(), gettxout(), gettxoutproof(), gettxoutsetinfo(), getwalletinfo(), importaddress(), importelectrumwallet(), importprivkey(), importpubkey(), importwallet(), invalidateblock(), keypoolrefill(), listaccounts(), listaddressbalances(), listaddressgroupings(), listbanned(), listlockunspent(), listreceivedbyaccount(), listreceivedbyaddress(), listsinceblock(), listtransactions(), listunspent(), listwallets(), loadwallet(), lockunspent(), logging(), movecmd(), ping(), preciousblock(), prioritisetransaction(), pruneblockchain(), quorum_list_help(), reconsiderblock(), removeprunedfunds(), rescanblockchain(), savemempool(), sendfrom(), sendmany(), sendrawtransaction(), sendtoaddress(), setaccount(), setban(), setprivatesendamount(), setprivatesendrounds(), settxfee(), signmessage(), signmessagewithprivkey(), signrawtransaction(), spork(), submitblock(), uptime(), validateaddress(), verifychain(), verifymessage(), verifytxoutproof(), waitforblock(), waitforblockheight(), waitfornewblock(), walletlock(), walletpassphrase(), and walletpassphrasechange().
◆ InterruptRPC()
void InterruptRPC | ( | ) |
Definition at line 375 of file server.cpp.
References fRPCRunning, LogPrint, and BCLog::RPC.
Referenced by Interrupt().
◆ IsDeprecatedRPCEnabled()
bool IsDeprecatedRPCEnabled | ( | const std::string & | method | ) |
Definition at line 447 of file server.cpp.
References gArgs, and ArgsManager::GetArgs().
Referenced by addmultisigaddress(), createmultisig(), estimatefee(), and getmininginfo().
◆ IsRPCRunning()
bool IsRPCRunning | ( | ) |
Query whether RPC is running.
Definition at line 390 of file server.cpp.
References fRPCRunning.
Referenced by CRPCTable::appendCommand(), getblocktemplate(), waitforblock(), waitforblockheight(), and waitfornewblock().
◆ JSONRPCExecBatch()
std::string JSONRPCExecBatch | ( | const JSONRPCRequest & | jreq, |
const UniValue & | vReq | ||
) |
Definition at line 477 of file server.cpp.
References JSONRPCExecOne(), UniValue::push_back(), UniValue::size(), UniValue::VARR, and UniValue::write().
Referenced by HTTPReq_JSONRPC().
◆ JSONRPCExecOne()
|
static |
Definition at line 454 of file server.cpp.
References CRPCTable::execute(), JSONRPCRequest::id, JSONRPCError(), JSONRPCReplyObj(), NullUniValue, JSONRPCRequest::parse(), RPC_PARSE_ERROR, tableRPC, and UniValue::VOBJ.
Referenced by JSONRPCExecBatch().
◆ ParseBoolV()
bool ParseBoolV | ( | const UniValue & | v, |
const std::string & | strName | ||
) |
Definition at line 179 of file server.cpp.
References UniValue::get_bool(), UniValue::get_int(), UniValue::get_str(), UniValue::isBool(), UniValue::isNum(), UniValue::isStr(), itostr(), JSONRPCError(), and RPC_INVALID_PARAMETER.
Referenced by protx_list(), and quorum_info().
◆ ParseDoubleV()
double ParseDoubleV | ( | const UniValue & | v, |
const std::string & | strName | ||
) |
Definition at line 170 of file server.cpp.
References UniValue::getValStr(), JSONRPCError(), ParseDouble(), and RPC_INVALID_PARAMETER.
Referenced by quorum_dkgsimerror().
◆ ParseHashO()
Definition at line 134 of file server.cpp.
References find_value(), and ParseHashV().
Referenced by createrawtransaction(), and signrawtransaction().
◆ ParseHashV()
Utilities: convert hex-encoded Values (throws error if not hex).
Definition at line 121 of file server.cpp.
References UniValue::get_str(), IsHex(), UniValue::isStr(), JSONRPCError(), RPC_INVALID_PARAMETER, base_blob< BITS >::SetHex(), and strprintf.
Referenced by getblockstats(), getmempoolancestors(), getmempooldescendants(), getmempoolentry(), getrawtransaction(), getspentinfo(), gobject_get(), gobject_getcurrentvotes(), gobject_submit(), gobject_vote_conf(), ParseBlock(), ParseHashO(), protx_info(), quorum_info(), quorum_memberof(), quorum_selectquorum(), quorum_sigs_cmd(), and voteraw().
◆ ParseHexO()
std::vector<unsigned char> ParseHexO | ( | const UniValue & | o, |
std::string | strKey | ||
) |
Definition at line 147 of file server.cpp.
References find_value(), and ParseHexV().
Referenced by signrawtransaction().
◆ ParseHexV()
std::vector<unsigned char> ParseHexV | ( | const UniValue & | v, |
std::string | strName | ||
) |
Definition at line 138 of file server.cpp.
References UniValue::get_str(), IsHex(), UniValue::isStr(), JSONRPCError(), ParseHex(), and RPC_INVALID_PARAMETER.
Referenced by createrawtransaction(), decodescript(), importprunedfunds(), ParseHexO(), signrawtransaction(), and verifytxoutproof().
◆ ParseInt32V()
int32_t ParseInt32V | ( | const UniValue & | v, |
const std::string & | strName | ||
) |
Definition at line 152 of file server.cpp.
References UniValue::getValStr(), JSONRPCError(), ParseInt32(), and RPC_INVALID_PARAMETER.
Referenced by ParseBlock(), protx_list(), quorum_dkgstatus(), quorum_info(), quorum_list(), quorum_memberof(), quorum_selectquorum(), and quorum_sigs_cmd().
◆ ParseInt64V()
int64_t ParseInt64V | ( | const UniValue & | v, |
const std::string & | strName | ||
) |
Definition at line 161 of file server.cpp.
References UniValue::getValStr(), JSONRPCError(), ParseInt64(), and RPC_INVALID_PARAMETER.
◆ RPCIsInWarmup()
bool RPCIsInWarmup | ( | std::string * | outStatus | ) |
Definition at line 408 of file server.cpp.
References cs_rpcWarmup, fRPCInWarmup, LOCK, and rpcWarmupStatus().
Referenced by CheckWarmup(), and PrepareShutdown().
◆ RPCRunLater()
void RPCRunLater | ( | const std::string & | name, |
std::function< void(void)> | func, | ||
int64_t | nSeconds | ||
) |
Run func nSeconds from now.
Overrides previous timer <name> (if any).
Definition at line 607 of file server.cpp.
References deadlineTimers, JSONRPCError(), LogPrint, name, RPCTimerInterface::Name(), RPCTimerInterface::NewTimer(), BCLog::RPC, RPC_INTERNAL_ERROR, and timerInterface.
Referenced by walletpassphrase().
◆ RPCSetTimerInterface()
void RPCSetTimerInterface | ( | RPCTimerInterface * | iface | ) |
Set the factory function for timers.
Definition at line 596 of file server.cpp.
References timerInterface.
Referenced by StartHTTPRPC().
◆ RPCSetTimerInterfaceIfUnset()
void RPCSetTimerInterfaceIfUnset | ( | RPCTimerInterface * | iface | ) |
Set the factory function for timer, but only, if unset.
Definition at line 590 of file server.cpp.
References timerInterface.
Referenced by RPCConsole::RPCConsole().
◆ RPCTypeCheck()
void RPCTypeCheck | ( | const UniValue & | params, |
const std::list< UniValue::VType > & | typesExpected, | ||
bool | fAllowNull = false |
||
) |
Type-check arguments; throws JSONRPCError if wrong type given.
Does not check that the right number of arguments are passed, just that any passed are the correct type.
Definition at line 54 of file server.cpp.
References UniValue::isNull(), RPCTypeCheckArgument(), and UniValue::size().
Referenced by createrawtransaction(), decoderawtransaction(), decodescript(), estimatefee(), estimaterawfee(), estimatesmartfee(), fundrawtransaction(), importmulti(), sendrawtransaction(), setmocktime(), and signrawtransaction().
◆ RPCTypeCheckArgument()
void RPCTypeCheckArgument | ( | const UniValue & | value, |
UniValue::VType | typeExpected | ||
) |
Type-check one argument; throws JSONRPCError if wrong type given.
Definition at line 72 of file server.cpp.
References JSONRPCError(), RPC_TYPE_ERROR, strprintf, UniValue::type(), and uvTypeName().
Referenced by estimaterawfee(), estimatesmartfee(), listunspent(), lockunspent(), and RPCTypeCheck().
◆ RPCTypeCheckObj()
void RPCTypeCheckObj | ( | const UniValue & | o, |
const std::map< std::string, UniValueType > & | typesExpected, | ||
bool | fAllowNull, | ||
bool | fStrict | ||
) |
Definition at line 79 of file server.cpp.
References find_value(), UniValue::getKeys(), UniValue::isNull(), JSONRPCError(), RPC_TYPE_ERROR, strprintf, UniValue::type(), and uvTypeName().
Referenced by fundrawtransaction(), lockunspent(), and signrawtransaction().
◆ RPCUnsetTimerInterface()
void RPCUnsetTimerInterface | ( | RPCTimerInterface * | iface | ) |
Unset factory function for timers.
Definition at line 601 of file server.cpp.
References timerInterface.
Referenced by StopHTTPRPC(), and RPCConsole::~RPCConsole().
◆ rpcWarmupStatus()
|
static |
Referenced by CRPCTable::execute(), RPCIsInWarmup(), and SetRPCWarmupStatus().
◆ SetRPCWarmupFinished()
void SetRPCWarmupFinished | ( | ) |
Definition at line 401 of file server.cpp.
References cs_rpcWarmup, fRPCInWarmup, and LOCK.
Referenced by AppInitMain().
◆ SetRPCWarmupStatus()
void SetRPCWarmupStatus | ( | const std::string & | newStatus | ) |
Set the RPC warmup status.
When this is done, all RPC calls will error out immediately with RPC_IN_WARMUP.
Definition at line 395 of file server.cpp.
References cs_rpcWarmup, LOCK, and rpcWarmupStatus().
Referenced by AppInitMain().
◆ StartRPC()
bool StartRPC | ( | ) |
Definition at line 367 of file server.cpp.
References fRPCRunning, g_rpcSignals, LogPrint, BCLog::RPC, and CRPCSignals::Started.
Referenced by AppInitServers().
◆ stop()
UniValue stop | ( | const JSONRPCRequest & | jsonRequest | ) |
Definition at line 286 of file server.cpp.
References JSONRPCRequest::fHelp, UniValue::get_int(), UniValue::isNum(), MilliSleep(), JSONRPCRequest::params, UniValue::size(), and StartShutdown().
Referenced by Random_SanityCheck().
◆ StopRPC()
void StopRPC | ( | ) |
Definition at line 382 of file server.cpp.
References deadlineTimers, DeleteAuthCookie(), g_rpcSignals, LogPrint, BCLog::RPC, and CRPCSignals::Stopped.
Referenced by PrepareShutdown().
◆ transformNamedArguments()
|
inlinestatic |
Process named arguments into a vector of positional arguments, based on the passed-in specification for the RPC call's arguments.
Definition at line 490 of file server.cpp.
References UniValue::getKeys(), UniValue::getValues(), JSONRPCError(), JSONRPCRequest::params, UniValue::push_back(), RPC_INVALID_PARAMETER, and UniValue::VARR.
Referenced by CRPCTable::execute().
◆ uptime()
UniValue uptime | ( | const JSONRPCRequest & | jsonRequest | ) |
Definition at line 305 of file server.cpp.
References JSONRPCRequest::fHelp, GetStartupTime(), GetTime(), HelpExampleCli(), HelpExampleRpc(), JSONRPCRequest::params, and UniValue::size().
Variable Documentation
◆ cs_rpcWarmup
|
static |
Definition at line 31 of file server.cpp.
Referenced by CRPCTable::execute(), RPCIsInWarmup(), SetRPCWarmupFinished(), and SetRPCWarmupStatus().
◆ deadlineTimers
|
static |
Definition at line 35 of file server.cpp.
Referenced by RPCRunLater(), and StopRPC().
◆ fRPCInWarmup
|
static |
Definition at line 29 of file server.cpp.
Referenced by CRPCTable::execute(), PrepareShutdown(), RPCIsInWarmup(), and SetRPCWarmupFinished().
◆ fRPCRunning
|
static |
Definition at line 28 of file server.cpp.
Referenced by InterruptRPC(), IsRPCRunning(), and StartRPC().
◆ g_rpcSignals
|
static |
Referenced by CRPCTable::execute(), RPCServer::OnStarted(), RPCServer::OnStopped(), StartRPC(), and StopRPC().
◆ tableRPC
CRPCTable tableRPC |
Definition at line 616 of file server.cpp.
Referenced by AppInitMain(), CRPCTable::execute(), help(), HTTPReq_JSONRPC(), JSONRPCExecOne(), RegisterEvoRPCCommands(), RegisterQuorumsRPCCommands(), RPCConsole::RPCParseCommandLine(), RPCConsole::setClientModel(), and WalletTestingSetup::WalletTestingSetup().
◆ timerInterface
|
static |
Definition at line 33 of file server.cpp.
Referenced by RPCRunLater(), RPCSetTimerInterface(), RPCSetTimerInterfaceIfUnset(), and RPCUnsetTimerInterface().
◆ vRPCCommands
|
static |
Call Table.
Definition at line 324 of file server.cpp.
Referenced by CRPCTable::CRPCTable().