Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

protocol.h File Reference
#include <fs.h>
#include <list>
#include <map>
#include <stdint.h>
#include <string>
#include <univalue.h>
+ Include dependency graph for protocol.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  HTTPStatusCode {
  HTTP_OK = 200, HTTP_BAD_REQUEST = 400, HTTP_UNAUTHORIZED = 401, HTTP_FORBIDDEN = 403,
  HTTP_NOT_FOUND = 404, HTTP_BAD_METHOD = 405, HTTP_INTERNAL_SERVER_ERROR = 500, HTTP_SERVICE_UNAVAILABLE = 503
}
 HTTP status codes. More...
 
enum  RPCErrorCode {
  RPC_INVALID_REQUEST = -32600, RPC_METHOD_NOT_FOUND = -32601, RPC_INVALID_PARAMS = -32602, RPC_INTERNAL_ERROR = -32603,
  RPC_PARSE_ERROR = -32700, RPC_MISC_ERROR = -1, RPC_FORBIDDEN_BY_SAFE_MODE = -2, RPC_TYPE_ERROR = -3,
  RPC_INVALID_ADDRESS_OR_KEY = -5, RPC_OUT_OF_MEMORY = -7, RPC_INVALID_PARAMETER = -8, RPC_DATABASE_ERROR = -20,
  RPC_DESERIALIZATION_ERROR = -22, RPC_VERIFY_ERROR = -25, RPC_VERIFY_REJECTED = -26, RPC_VERIFY_ALREADY_IN_CHAIN = -27,
  RPC_IN_WARMUP = -28, RPC_METHOD_DEPRECATED = -32, RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR, RPC_TRANSACTION_REJECTED = RPC_VERIFY_REJECTED,
  RPC_TRANSACTION_ALREADY_IN_CHAIN = RPC_VERIFY_ALREADY_IN_CHAIN, RPC_CLIENT_NOT_CONNECTED = -9, RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, RPC_CLIENT_NODE_ALREADY_ADDED = -23,
  RPC_CLIENT_NODE_NOT_ADDED = -24, RPC_CLIENT_NODE_NOT_CONNECTED = -29, RPC_CLIENT_INVALID_IP_OR_SUBNET = -30, RPC_CLIENT_P2P_DISABLED = -31,
  RPC_WALLET_ERROR = -4, RPC_WALLET_INSUFFICIENT_FUNDS = -6, RPC_WALLET_INVALID_ACCOUNT_NAME = -11, RPC_WALLET_KEYPOOL_RAN_OUT = -12,
  RPC_WALLET_UNLOCK_NEEDED = -13, RPC_WALLET_PASSPHRASE_INCORRECT = -14, RPC_WALLET_WRONG_ENC_STATE = -15, RPC_WALLET_ENCRYPTION_FAILED = -16,
  RPC_WALLET_ALREADY_UNLOCKED = -17, RPC_WALLET_NOT_FOUND = -18, RPC_WALLET_NOT_SPECIFIED = -19
}
 Dash Core RPC error codes. More...
 

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)
 
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...
 

Enumeration Type Documentation

◆ HTTPStatusCode

HTTP status codes.

Enumerator
HTTP_OK 
HTTP_BAD_REQUEST 
HTTP_UNAUTHORIZED 
HTTP_FORBIDDEN 
HTTP_NOT_FOUND 
HTTP_BAD_METHOD 
HTTP_INTERNAL_SERVER_ERROR 
HTTP_SERVICE_UNAVAILABLE 

Definition at line 19 of file protocol.h.

◆ RPCErrorCode

Dash Core RPC error codes.

Enumerator
RPC_INVALID_REQUEST 

Standard JSON-RPC 2.0 errors.

RPC_METHOD_NOT_FOUND 
RPC_INVALID_PARAMS 
RPC_INTERNAL_ERROR 
RPC_PARSE_ERROR 
RPC_MISC_ERROR 

General application defined errors.

std::exception thrown in command handling

RPC_FORBIDDEN_BY_SAFE_MODE 

Server is in safe mode, and command is not allowed in safe mode.

RPC_TYPE_ERROR 

Unexpected type was passed as parameter.

RPC_INVALID_ADDRESS_OR_KEY 

Invalid address or key.

RPC_OUT_OF_MEMORY 

Ran out of memory during operation.

RPC_INVALID_PARAMETER 

Invalid, missing or duplicate parameter.

RPC_DATABASE_ERROR 

Database error.

RPC_DESERIALIZATION_ERROR 

Error parsing or validating structure in raw format.

RPC_VERIFY_ERROR 

General error during transaction or block submission.

RPC_VERIFY_REJECTED 

Transaction or block was rejected by network rules.

RPC_VERIFY_ALREADY_IN_CHAIN 

Transaction already in chain.

RPC_IN_WARMUP 

Client still warming up.

RPC_METHOD_DEPRECATED 

RPC method is deprecated.

RPC_TRANSACTION_ERROR 

Aliases for backward compatibility.

RPC_TRANSACTION_REJECTED 
RPC_TRANSACTION_ALREADY_IN_CHAIN 
RPC_CLIENT_NOT_CONNECTED 

P2P client errors.

Dash is not connected

RPC_CLIENT_IN_INITIAL_DOWNLOAD 

Still downloading initial blocks.

RPC_CLIENT_NODE_ALREADY_ADDED 

Node is already added.

RPC_CLIENT_NODE_NOT_ADDED 

Node has not been added before.

RPC_CLIENT_NODE_NOT_CONNECTED 

Node to disconnect not found in connected nodes.

RPC_CLIENT_INVALID_IP_OR_SUBNET 

Invalid IP/Subnet.

RPC_CLIENT_P2P_DISABLED 

No valid connection manager instance found.

RPC_WALLET_ERROR 

Wallet errors.

Unspecified problem with wallet (key not found etc.)

RPC_WALLET_INSUFFICIENT_FUNDS 

Not enough funds in wallet or account.

RPC_WALLET_INVALID_ACCOUNT_NAME 

Invalid account name.

RPC_WALLET_KEYPOOL_RAN_OUT 

Keypool ran out, call keypoolrefill first.

RPC_WALLET_UNLOCK_NEEDED 

Enter the wallet passphrase with walletpassphrase first.

RPC_WALLET_PASSPHRASE_INCORRECT 

The wallet passphrase entered was incorrect.

RPC_WALLET_WRONG_ENC_STATE 

Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)

RPC_WALLET_ENCRYPTION_FAILED 

Failed to encrypt the wallet.

RPC_WALLET_ALREADY_UNLOCKED 

Wallet is already unlocked.

RPC_WALLET_NOT_FOUND 

Invalid wallet specified.

RPC_WALLET_NOT_SPECIFIED 

No wallet specified (error when there are multiple wallets loaded)

Definition at line 32 of file protocol.h.

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().

◆ 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().

Released under the MIT license