![]() |
Master Core
v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
|
#include "rpcserver.h"
#include "base58.h"
#include "init.h"
#include "main.h"
#include "ui_interface.h"
#include "util.h"
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/shared_ptr.hpp>
#include "json/json_spirit_writer_template.h"
Go to the source code of this file.
Classes | |
class | AcceptedConnection |
class | AcceptedConnectionImpl< Protocol > |
class | JSONRequest |
Functions | |
void | RPCTypeCheck (const Array ¶ms, const list< Value_type > &typesExpected, bool fAllowNull) |
void | RPCTypeCheck (const Object &o, const map< string, Value_type > &typesExpected, bool fAllowNull) |
int64_t | AmountFromValue (const Value &value) |
Value | ValueFromAmount (int64_t amount) |
std::string | HexBits (unsigned int nBits) |
uint256 | ParseHashV (const Value &v, string strName) |
uint256 | ParseHashO (const Object &o, string strKey) |
vector< unsigned char > | ParseHexV (const Value &v, string strName) |
vector< unsigned char > | ParseHexO (const Object &o, string strKey) |
Value | help (const Array ¶ms, bool fHelp) |
Value | stop (const Array ¶ms, bool fHelp) |
bool | HTTPAuthorized (map< string, string > &mapHeaders) |
void | ErrorReply (std::ostream &stream, const Object &objError, const Value &id) |
bool | ClientAllowed (const boost::asio::ip::address &address) |
void | ServiceConnection (AcceptedConnection *conn) |
template<typename Protocol , typename SocketAcceptorService > | |
static void | RPCAcceptHandler (boost::shared_ptr< basic_socket_acceptor< Protocol, SocketAcceptorService > > acceptor, ssl::context &context, const bool fUseSSL, boost::shared_ptr< AcceptedConnection > conn, const boost::system::error_code &error) |
Accept and handle incoming connection. More... | |
template<typename Protocol , typename SocketAcceptorService > | |
static void | RPCListen (boost::shared_ptr< basic_socket_acceptor< Protocol, SocketAcceptorService > > acceptor, ssl::context &context, const bool fUseSSL) |
Sets up I/O resources to accept and handle a new connection. More... | |
void | StartRPCThreads () |
void | StartDummyRPCThread () |
void | StopRPCThreads () |
void | RPCRunHandler (const boost::system::error_code &err, boost::function< void(void)> func) |
void | RPCRunLater (const std::string &name, boost::function< void(void)> func, int64_t nSeconds) |
static Object | JSONRPCExecOne (const Value &req) |
static string | JSONRPCExecBatch (const Array &vReq) |
std::string | HelpExampleCli (string methodname, string args) |
std::string | HelpExampleRpc (string methodname, string args) |
Variables | |
static std::string | strRPCUserColonPass |
static asio::io_service * | rpc_io_service = NULL |
static map< string, boost::shared_ptr< deadline_timer > > | deadlineTimers |
static ssl::context * | rpc_ssl_context = NULL |
static boost::thread_group * | rpc_worker_group = NULL |
static boost::asio::io_service::work * | rpc_dummy_work = NULL |
static std::vector< boost::shared_ptr< ip::tcp::acceptor > > | rpc_acceptors |
static const CRPCCommand | vRPCCommands [] |
const CRPCTable | tableRPC |
int64_t AmountFromValue | ( | const Value & | value | ) |
Definition at line 83 of file rpcserver.cpp.
References COIN, JSONRPCError(), MoneyRange(), roundint64(), and RPC_TYPE_ERROR.
Referenced by createrawtransaction(), movecmd(), sendfrom(), sendmany(), sendtoaddress(), and settxfee().
bool ClientAllowed | ( | const boost::asio::ip::address & | address | ) |
Definition at line 391 of file rpcserver.cpp.
References mapMultiArgs, and WildcardMatch().
Referenced by RPCAcceptHandler().
void ErrorReply | ( | std::ostream & | stream, |
const Object & | objError, | ||
const Value & | id | ||
) |
Definition at line 380 of file rpcserver.cpp.
References HTTP_BAD_REQUEST, HTTP_INTERNAL_SERVER_ERROR, HTTP_NOT_FOUND, HTTPReply(), JSONRPCReply(), RPC_INVALID_REQUEST, and RPC_METHOD_NOT_FOUND.
Referenced by ServiceConnection().
Value help | ( | const Array & | params, |
bool | fHelp | ||
) |
Definition at line 184 of file rpcserver.cpp.
References CRPCTable::help(), and tableRPC.
Referenced by BitcoinGUI::createMenuBar(), main(), and BitcoinGUI::showHelpMessageClicked().
std::string HelpExampleCli | ( | string | methodname, |
string | args | ||
) |
Definition at line 919 of file rpcserver.cpp.
Referenced by addmultisigaddress(), addnode(), backupwallet(), createmultisig(), createrawtransaction(), decoderawtransaction(), decodescript(), dumpprivkey(), dumpwallet(), encryptwallet(), getaccount(), getaccountaddress(), getactivecrowdsales_MP(), getactivedexsells_MP(), getaddednodeinfo(), getaddressesbyaccount(), getallbalancesforaddress_MP(), getallbalancesforid_MP(), getbalance(), getbestblockhash(), getblock(), getblockchaininfo(), getblockcount(), getblockhash(), getblocktemplate(), getconnectioncount(), getcrowdsale_MP(), getdifficulty(), getgrants_MP(), getinfo(), getmininginfo(), getnettotals(), getnetworkhashps(), getnetworkinfo(), getnewaddress(), getpeerinfo(), getproperty_MP(), getrawchangeaddress(), getrawmempool(), getrawtransaction(), getreceivedbyaccount(), getreceivedbyaddress(), getsto_MP(), gettrade_MP(), gettransaction(), gettransaction_MP(), gettxout(), gettxoutsetinfo(), getwalletinfo(), importprivkey(), importwallet(), keypoolrefill(), listaccounts(), listaddressgroupings(), listblocktransactions_MP(), listlockunspent(), listproperties_MP(), listreceivedbyaccount(), listreceivedbyaddress(), listsinceblock(), listtransactions(), listtransactions_MP(), lockunspent(), movecmd(), mscrpc(), ping(), sendfrom(), sendmany(), sendrawtransaction(), sendtoaddress(), setaccount(), settxfee(), signmessage(), signrawtransaction(), submitblock(), validateaddress(), verifychain(), verifymessage(), walletlock(), walletpassphrase(), and walletpassphrasechange().
std::string HelpExampleRpc | ( | string | methodname, |
string | args | ||
) |
Definition at line 923 of file rpcserver.cpp.
Referenced by addmultisigaddress(), addnode(), backupwallet(), createmultisig(), createrawtransaction(), decoderawtransaction(), decodescript(), dumpprivkey(), dumpwallet(), encryptwallet(), getaccount(), getaccountaddress(), getactivecrowdsales_MP(), getactivedexsells_MP(), getaddednodeinfo(), getaddressesbyaccount(), getallbalancesforaddress_MP(), getallbalancesforid_MP(), getbalance(), getbestblockhash(), getblock(), getblockchaininfo(), getblockcount(), getblockhash(), getblocktemplate(), getconnectioncount(), getcrowdsale_MP(), getdifficulty(), getgrants_MP(), getinfo(), getmininginfo(), getnettotals(), getnetworkhashps(), getnetworkinfo(), getnewaddress(), getpeerinfo(), getproperty_MP(), getrawchangeaddress(), getrawmempool(), getrawtransaction(), getreceivedbyaccount(), getreceivedbyaddress(), getsto_MP(), gettrade_MP(), gettransaction(), gettransaction_MP(), gettxout(), gettxoutsetinfo(), getwalletinfo(), importprivkey(), importwallet(), keypoolrefill(), listaccounts(), listaddressgroupings(), listblocktransactions_MP(), listlockunspent(), listproperties_MP(), listreceivedbyaccount(), listreceivedbyaddress(), listsinceblock(), listtransactions(), listtransactions_MP(), lockunspent(), movecmd(), mscrpc(), ping(), sendfrom(), sendmany(), sendrawtransaction(), sendtoaddress(), setaccount(), settxfee(), signmessage(), signrawtransaction(), submitblock(), validateaddress(), verifychain(), verifymessage(), walletlock(), walletpassphrase(), and walletpassphrasechange().
std::string HexBits | ( | unsigned int | nBits | ) |
Definition at line 99 of file rpcserver.cpp.
References BEGIN, END, and HexStr().
Referenced by blockToJSON(), and getblocktemplate().
bool HTTPAuthorized | ( | map< string, string > & | mapHeaders | ) |
Definition at line 370 of file rpcserver.cpp.
References DecodeBase64(), strRPCUserColonPass, and TimingResistantEqual().
Referenced by ServiceConnection().
|
static |
Definition at line 781 of file rpcserver.cpp.
References JSONRPCExecOne().
Referenced by ServiceConnection().
|
static |
Definition at line 757 of file rpcserver.cpp.
References CRPCTable::execute(), JSONRequest::id, JSONRPCError(), JSONRPCReplyObj(), JSONRequest::params, JSONRequest::parse(), RPC_PARSE_ERROR, JSONRequest::strMethod, and tableRPC.
Referenced by JSONRPCExecBatch().
uint256 ParseHashO | ( | const Object & | o, |
string | strKey | ||
) |
Definition at line 120 of file rpcserver.cpp.
References ParseHashV().
Referenced by createrawtransaction(), and signrawtransaction().
uint256 ParseHashV | ( | const Value & | v, |
string | strName | ||
) |
Definition at line 109 of file rpcserver.cpp.
References IsHex(), JSONRPCError(), RPC_INVALID_PARAMETER, and base_uint< BITS >::SetHex().
Referenced by getrawtransaction(), and ParseHashO().
vector<unsigned char> ParseHexO | ( | const Object & | o, |
string | strKey | ||
) |
Definition at line 133 of file rpcserver.cpp.
References ParseHexV().
Referenced by signrawtransaction().
vector<unsigned char> ParseHexV | ( | const Value & | v, |
string | strName | ||
) |
Definition at line 124 of file rpcserver.cpp.
References IsHex(), JSONRPCError(), ParseHex(), and RPC_INVALID_PARAMETER.
Referenced by decoderawtransaction(), decodescript(), ParseHexO(), sendrawtransaction(), and signrawtransaction().
|
static |
Accept and handle incoming connection.
Definition at line 498 of file rpcserver.cpp.
References ClientAllowed(), HTTP_FORBIDDEN, HTTPReply(), LogPrintf, AcceptedConnectionImpl< Protocol >::peer, RPCListen(), and ServiceConnection().
|
static |
Sets up I/O resources to accept and handle a new connection.
Definition at line 475 of file rpcserver.cpp.
Referenced by RPCAcceptHandler(), and StartRPCThreads().
void RPCRunHandler | ( | const boost::system::error_code & | err, |
boost::function< void(void)> | func | ||
) |
Definition at line 696 of file rpcserver.cpp.
Referenced by RPCRunLater().
void RPCRunLater | ( | const std::string & | name, |
boost::function< void(void)> | func, | ||
int64_t | nSeconds | ||
) |
Definition at line 702 of file rpcserver.cpp.
References rpc_io_service, and RPCRunHandler().
Referenced by walletpassphrase().
void RPCTypeCheck | ( | const Array & | params, |
const list< Value_type > & | typesExpected, | ||
bool | fAllowNull | ||
) |
Definition at line 43 of file rpcserver.cpp.
References JSONRPCError(), RPC_TYPE_ERROR, and strprintf.
Referenced by createrawtransaction(), decodescript(), lockunspent(), and signrawtransaction().
void RPCTypeCheck | ( | const Object & | o, |
const map< string, Value_type > & | typesExpected, | ||
bool | fAllowNull | ||
) |
Definition at line 64 of file rpcserver.cpp.
References JSONRPCError(), PAIRTYPE, RPC_TYPE_ERROR, and strprintf.
void ServiceConnection | ( | AcceptedConnection * | conn | ) |
Definition at line 790 of file rpcserver.cpp.
References ErrorReply(), CRPCTable::execute(), HTTP_NOT_FOUND, HTTP_OK, HTTP_UNAUTHORIZED, HTTPAuthorized(), HTTPReply(), JSONRequest::id, JSONRPCError(), JSONRPCExecBatch(), JSONRPCReply(), LogPrintf, mapArgs, MilliSleep(), JSONRequest::params, JSONRequest::parse(), AcceptedConnection::peer_address_to_string(), ReadHTTPMessage(), ReadHTTPRequestLine(), RPC_PARSE_ERROR, ShutdownRequested(), AcceptedConnection::stream(), JSONRequest::strMethod, and tableRPC.
Referenced by RPCAcceptHandler().
void StartDummyRPCThread | ( | ) |
Definition at line 651 of file rpcserver.cpp.
References rpc_dummy_work, rpc_io_service, and rpc_worker_group.
Referenced by BitcoinCore::initialize().
void StartRPCThreads | ( | ) |
Definition at line 531 of file rpcserver.cpp.
References _(), EncodeBase58(), GetArg(), GetBoolArg(), GetConfigFile(), GetDataDir(), LogPrintf, mapArgs, CClientUIInterface::MSG_ERROR, Params(), rpc_io_service, rpc_ssl_context, rpc_worker_group, RPCListen(), StartShutdown(), strprintf, strRPCUserColonPass, CClientUIInterface::ThreadSafeMessageBox, and uiInterface.
Referenced by AppInit2().
Value stop | ( | const Array & | params, |
bool | fHelp | ||
) |
Definition at line 204 of file rpcserver.cpp.
References StartShutdown().
void StopRPCThreads | ( | ) |
Definition at line 664 of file rpcserver.cpp.
References LogPrintf, PAIRTYPE, rpc_dummy_work, rpc_io_service, rpc_ssl_context, and rpc_worker_group.
Referenced by Shutdown().
Value ValueFromAmount | ( | int64_t | amount | ) |
Definition at line 94 of file rpcserver.cpp.
References COIN.
Referenced by AcentryToJSON(), getbalance(), getinfo(), getnetworkinfo(), getrawmempool(), getreceivedbyaddress(), gettransaction(), gettxout(), gettxoutsetinfo(), getunconfirmedbalance(), getwalletinfo(), listaccounts(), listaddressgroupings(), ListReceived(), ListTransactions(), populateRPCTransactionObject(), and TxToJSON().
|
static |
Definition at line 37 of file rpcserver.cpp.
|
static |
Definition at line 41 of file rpcserver.cpp.
|
static |
Definition at line 40 of file rpcserver.cpp.
Referenced by StartDummyRPCThread(), and StopRPCThreads().
|
static |
Definition at line 36 of file rpcserver.cpp.
Referenced by RPCRunLater(), StartDummyRPCThread(), StartRPCThreads(), and StopRPCThreads().
|
static |
Definition at line 38 of file rpcserver.cpp.
Referenced by StartRPCThreads(), and StopRPCThreads().
|
static |
Definition at line 39 of file rpcserver.cpp.
Referenced by StartDummyRPCThread(), StartRPCThreads(), and StopRPCThreads().
|
static |
Definition at line 33 of file rpcserver.cpp.
Referenced by HTTPAuthorized(), and StartRPCThreads().
const CRPCTable tableRPC |
Definition at line 928 of file rpcserver.cpp.
Referenced by CRPCTable::execute(), help(), JSONRPCExecOne(), RPCExecutor::request(), and ServiceConnection().
|
static |
Definition at line 223 of file rpcserver.cpp.
Referenced by CRPCTable::CRPCTable().