Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

protocol.cpp File Reference
#include <rpc/protocol.h>
#include <random.h>
#include <tinyformat.h>
#include <util.h>
#include <utilstrencodings.h>
#include <utiltime.h>
#include <version.h>
#include <fstream>
+ Include dependency graph for protocol.cpp:

Go to the source code of this file.

Functions

UniValue JSONRPCRequestObj (const std::string &strMethod, const UniValue &params, const UniValue &id)
 JSON-RPC protocol. More...
 
UniValue JSONRPCReplyObj (const UniValue &result, const UniValue &error, const UniValue &id)
 
std::string JSONRPCReply (const UniValue &result, const UniValue &error, const UniValue &id)
 
UniValue JSONRPCError (int code, const std::string &message)
 
static fs::path GetAuthCookieFile (bool temp=false)
 Get name of RPC authentication cookie file. More...
 
bool GenerateAuthCookie (std::string *cookie_out)
 Generate a new RPC authentication cookie and write it to disk. More...
 
bool GetAuthCookie (std::string *cookie_out)
 Read the RPC authentication cookie from disk. More...
 
void DeleteAuthCookie ()
 Delete RPC authentication cookie from disk. More...
 
std::vector< UniValueJSONRPCProcessBatchReply (const UniValue &in, size_t num)
 Parse JSON-RPC batch reply into a vector. More...
 

Variables

static const std::string COOKIEAUTH_USER = "__cookie__"
 Username used when cookie authentication is in use (arbitrary, only for recognizability in debugging/logging purposes) More...
 
static const std::string COOKIEAUTH_FILE = ".cookie"
 Default name for auth cookie file. More...
 

Function Documentation

◆ DeleteAuthCookie()

void DeleteAuthCookie ( )

Delete RPC authentication cookie from disk.

Definition at line 128 of file protocol.cpp.

References GetAuthCookieFile(), and LogPrintf.

Referenced by StopRPC().

◆ GenerateAuthCookie()

bool GenerateAuthCookie ( std::string *  cookie_out)

Generate a new RPC authentication cookie and write it to disk.

the umask determines what permissions are used to create this file - these are set to 077 in init.cpp unless overridden with -sysperms.

Definition at line 79 of file protocol.cpp.

References COOKIEAUTH_USER, GetAuthCookieFile(), GetRandBytes(), HexStr(), LogPrintf, and RenameOver().

Referenced by InitRPCAuthentication().

◆ GetAuthCookie()

bool GetAuthCookie ( std::string *  cookie_out)

Read the RPC authentication cookie from disk.

Definition at line 112 of file protocol.cpp.

References GetAuthCookieFile().

Referenced by CallRPC().

◆ GetAuthCookieFile()

static fs::path GetAuthCookieFile ( bool  temp = false)
static

Get name of RPC authentication cookie file.

Definition at line 70 of file protocol.cpp.

References AbsPathForConfigVal(), COOKIEAUTH_FILE, gArgs, and ArgsManager::GetArg().

Referenced by DeleteAuthCookie(), GenerateAuthCookie(), and GetAuthCookie().

◆ JSONRPCError()

UniValue JSONRPCError ( int  code,
const std::string &  message 
)

Definition at line 54 of file protocol.cpp.

References error(), Pair(), and UniValue::VOBJ.

Referenced by abandontransaction(), AccountFromValue(), addnode(), AddrToPubKey(), AmountFromValue(), backupwallet(), BIP22ValidationResult(), bls_fromsecret(), clearbanned(), combinerawtransaction(), createmultisig(), CreateMultisigRedeemscript(), createrawtransaction(), decoderawtransaction(), disconnectnode(), dumphdinfo(), dumpprivkey(), dumpwallet(), encryptwallet(), EnsureWalletIsAvailable(), EnsureWalletIsUnlocked(), estimatefee(), estimaterawfee(), estimatesmartfee(), CRPCTable::execute(), fundrawtransaction(), getaccount(), GetAccountDestination(), getaddednodeinfo(), getaddressbalance(), getaddressdeltas(), getAddressesFromParams(), getaddressmempool(), getaddresstxids(), getaddressutxos(), getbalance(), getbestchainlock(), getblock(), GetBlockChecked(), getblockhash(), getblockhashes(), getblockheader(), getblockheaders(), getblockstats(), getblocktemplate(), getCategoryMask(), getchaintxstats(), getconnectioncount(), GetImportTimestamp(), getinfo_deprecated(), getmemoryinfo(), getmempoolancestors(), getmempooldescendants(), getmempoolentry(), getmerkleblocks(), getnettotals(), getnewaddress(), getpeerinfo(), getrawchangeaddress(), getrawtransaction(), getreceivedbyaddress(), getspecialtxes(), getspentinfo(), getsuperblockbudget(), gettransaction(), gettxoutproof(), gettxoutsetinfo(), GetWalletForJSONRPCRequest(), gobject_check(), gobject_get(), gobject_getcurrentvotes(), gobject_submit(), gobject_vote_conf(), HexToPubKey(), HTTPReq_JSONRPC(), importaddress(), importelectrumwallet(), importmulti(), importprivkey(), importprunedfunds(), importpubkey(), ImportScript(), importwallet(), invalidateblock(), JSONRPCExecOne(), keypoolrefill(), listaddressbalances(), listbanned(), listsinceblock(), listtransactions(), listunspent(), loadwallet(), lockunspent(), logging(), masternode_connect(), masternode_count(), masternode_status(), movecmd(), ObserveSafeMode(), JSONRPCRequest::parse(), ParseBLSPubKey(), ParseBLSSecretKey(), ParseBoolV(), ParseConfirmTarget(), ParseDoubleV(), ParseHashV(), ParseHexV(), ParseInt32V(), ParseInt64V(), ParsePubKeyIDFromAddress(), ping(), preciousblock(), ProcessImport(), protx_info(), protx_list(), pruneblockchain(), quorum_dkgsimerror(), quorum_dkgstatus(), quorum_info(), quorum_list(), quorum_memberof(), quorum_selectquorum(), quorum_sigs_cmd(), reconsiderblock(), removeprunedfunds(), rescanblockchain(), resendwallettransactions(), RPCRunLater(), RPCTypeCheckArgument(), RPCTypeCheckObj(), savemempool(), sendfrom(), sendmany(), SendMoney(), sendrawtransaction(), sendtoaddress(), setaccount(), setban(), setnetworkactive(), setprivatesendamount(), setprivatesendrounds(), signmessage(), signmessagewithprivkey(), signrawtransaction(), spork(), submitblock(), transformNamedArguments(), verifymessage(), verifytxoutproof(), voteraw(), VoteWithMasternodes(), walletlock(), walletpassphrase(), and walletpassphrasechange().

◆ JSONRPCProcessBatchReply()

std::vector<UniValue> JSONRPCProcessBatchReply ( const UniValue in,
size_t  num 
)

Parse JSON-RPC batch reply into a vector.

Definition at line 137 of file protocol.cpp.

References UniValue::get_int(), UniValue::isArray(), UniValue::isObject(), and UniValue::size().

Referenced by GetinfoRequestHandler::ProcessReply().

◆ JSONRPCReply()

std::string JSONRPCReply ( const UniValue result,
const UniValue error,
const UniValue id 
)

Definition at line 48 of file protocol.cpp.

References error(), JSONRPCReplyObj(), and UniValue::write().

Referenced by HTTPReq_JSONRPC(), and JSONErrorReply().

◆ JSONRPCReplyObj()

UniValue JSONRPCReplyObj ( const UniValue result,
const UniValue error,
const UniValue id 
)

◆ JSONRPCRequestObj()

UniValue JSONRPCRequestObj ( const std::string &  strMethod,
const UniValue params,
const UniValue id 
)

JSON-RPC protocol.

Bitcoin speaks version 1.0 for maximum compatibility, but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were unspecified (HTTP errors and contents of 'error').

1.0 spec: http://json-rpc.org/wiki/specification 1.2 spec: http://jsonrpc.org/historical/json-rpc-over-http.html

Definition at line 27 of file protocol.cpp.

References Pair(), UniValue::push_back(), and UniValue::VOBJ.

Referenced by GetinfoRequestHandler::PrepareRequest(), and DefaultRequestHandler::PrepareRequest().

Variable Documentation

◆ COOKIEAUTH_FILE

const std::string COOKIEAUTH_FILE = ".cookie"
static

Default name for auth cookie file.

Definition at line 67 of file protocol.cpp.

Referenced by GetAuthCookieFile().

◆ COOKIEAUTH_USER

const std::string COOKIEAUTH_USER = "__cookie__"
static

Username used when cookie authentication is in use (arbitrary, only for recognizability in debugging/logging purposes)

Definition at line 65 of file protocol.cpp.

Referenced by GenerateAuthCookie().

Released under the MIT license