2010-07-14 17:54:31 +02:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2015-12-13 14:51:43 +01:00
|
|
|
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
2014-10-30 03:14:08 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2010-07-14 17:54:31 +02:00
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_RPCSERVER_H
|
|
|
|
#define BITCOIN_RPCSERVER_H
|
2012-04-21 01:37:34 +02:00
|
|
|
|
2014-04-23 00:46:19 +02:00
|
|
|
#include "amount.h"
|
2013-11-20 14:18:57 +01:00
|
|
|
#include "rpcprotocol.h"
|
2014-10-31 09:36:30 +01:00
|
|
|
#include "uint256.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2012-06-23 00:36:42 +02:00
|
|
|
#include <list>
|
2012-04-21 01:37:34 +02:00
|
|
|
#include <map>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
2012-08-21 17:03:38 +02:00
|
|
|
|
2014-08-20 21:15:16 +02:00
|
|
|
#include <boost/function.hpp>
|
2015-05-18 14:02:18 +02:00
|
|
|
|
2015-09-04 16:11:34 +02:00
|
|
|
#include <univalue.h>
|
2012-04-21 01:37:34 +02:00
|
|
|
|
2014-10-19 10:46:17 +02:00
|
|
|
class CRPCCommand;
|
|
|
|
|
|
|
|
namespace RPCServer
|
|
|
|
{
|
|
|
|
void OnStarted(boost::function<void ()> slot);
|
|
|
|
void OnStopped(boost::function<void ()> slot);
|
|
|
|
void OnPreCommand(boost::function<void (const CRPCCommand&)> slot);
|
|
|
|
void OnPostCommand(boost::function<void (const CRPCCommand&)> slot);
|
|
|
|
}
|
2012-04-21 01:37:34 +02:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
class CBlockIndex;
|
2014-04-28 15:23:29 +02:00
|
|
|
class CNetAddr;
|
2012-05-24 05:20:07 +02:00
|
|
|
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
class JSONRequest
|
2014-06-27 06:10:53 +02:00
|
|
|
{
|
|
|
|
public:
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
UniValue id;
|
|
|
|
std::string strMethod;
|
|
|
|
UniValue params;
|
2012-05-24 05:20:07 +02:00
|
|
|
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
JSONRequest() { id = NullUniValue; }
|
|
|
|
void parse(const UniValue& valRequest);
|
2014-06-27 06:10:53 +02:00
|
|
|
};
|
|
|
|
|
2014-11-20 03:19:29 +01:00
|
|
|
/** Query whether RPC is running */
|
2012-05-13 06:43:24 +02:00
|
|
|
bool IsRPCRunning();
|
2012-04-09 21:07:25 +02:00
|
|
|
|
2015-05-31 15:36:44 +02:00
|
|
|
/**
|
2014-11-20 03:19:29 +01:00
|
|
|
* Set the RPC warmup status. When this is done, all RPC calls will error out
|
2014-10-29 18:08:31 +01:00
|
|
|
* immediately with RPC_IN_WARMUP.
|
|
|
|
*/
|
|
|
|
void SetRPCWarmupStatus(const std::string& newStatus);
|
|
|
|
/* Mark warmup as done. RPC calls will be processed from now on. */
|
|
|
|
void SetRPCWarmupFinished();
|
|
|
|
|
2014-11-26 13:51:02 +01:00
|
|
|
/* returns the current warmup state. */
|
|
|
|
bool RPCIsInWarmup(std::string *statusOut);
|
2012-04-09 21:07:25 +02:00
|
|
|
|
2014-10-30 03:14:08 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type));
|
|
|
|
*/
|
2015-05-13 21:29:19 +02:00
|
|
|
void RPCTypeCheck(const UniValue& params,
|
|
|
|
const std::list<UniValue::VType>& typesExpected, bool fAllowNull=false);
|
2014-08-20 21:15:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Check for expected keys/value types in an Object.
|
|
|
|
Use like: RPCTypeCheckObj(object, boost::assign::map_list_of("name", str_type)("value", int_type));
|
|
|
|
*/
|
|
|
|
void RPCTypeCheckObj(const UniValue& o,
|
|
|
|
const std::map<std::string, UniValue::VType>& typesExpected, bool fAllowNull=false);
|
2012-06-23 00:36:42 +02:00
|
|
|
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
/** Opaque base class for timers returned by NewTimerFunc.
|
|
|
|
* This provides no methods at the moment, but makes sure that delete
|
|
|
|
* cleans up the whole state.
|
|
|
|
*/
|
|
|
|
class RPCTimerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~RPCTimerBase() {}
|
|
|
|
};
|
|
|
|
|
2014-10-30 03:14:08 +01:00
|
|
|
/**
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
* RPC timer "driver".
|
2014-10-30 03:14:08 +01:00
|
|
|
*/
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
class RPCTimerInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~RPCTimerInterface() {}
|
|
|
|
/** Implementation name */
|
|
|
|
virtual const char *Name() = 0;
|
|
|
|
/** Factory function for timers.
|
2015-08-28 16:46:20 +02:00
|
|
|
* RPC will call the function to create a timer that will call func in *millis* milliseconds.
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
* @note As the RPC mechanism is backend-neutral, it can use different implementations of timers.
|
|
|
|
* This is needed to cope with the case in which there is no HTTP server, but
|
|
|
|
* only GUI RPC console, and to break the dependency of pcserver on httprpc.
|
|
|
|
*/
|
2015-08-28 16:46:20 +02:00
|
|
|
virtual RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) = 0;
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Register factory function for timers */
|
|
|
|
void RPCRegisterTimerInterface(RPCTimerInterface *iface);
|
|
|
|
/** Unregister factory function for timers */
|
|
|
|
void RPCUnregisterTimerInterface(RPCTimerInterface *iface);
|
2012-06-23 00:36:42 +02:00
|
|
|
|
2014-10-30 03:14:08 +01:00
|
|
|
/**
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
* Run func nSeconds from now.
|
2014-10-30 03:14:08 +01:00
|
|
|
* Overrides previous timer <name> (if any).
|
2013-05-07 16:47:00 +02:00
|
|
|
*/
|
2013-04-13 07:13:08 +02:00
|
|
|
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
|
2013-05-07 16:47:00 +02:00
|
|
|
|
2015-05-13 21:29:19 +02:00
|
|
|
typedef UniValue(*rpcfn_type)(const UniValue& params, bool fHelp);
|
2012-04-21 01:37:34 +02:00
|
|
|
|
|
|
|
class CRPCCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-07-15 21:38:52 +02:00
|
|
|
std::string category;
|
2012-04-21 01:37:34 +02:00
|
|
|
std::string name;
|
|
|
|
rpcfn_type actor;
|
|
|
|
bool okSafeMode;
|
|
|
|
};
|
|
|
|
|
2012-04-09 21:07:25 +02:00
|
|
|
/**
|
2015-03-18 00:06:58 +01:00
|
|
|
* Dash RPC command dispatcher.
|
2012-04-09 21:07:25 +02:00
|
|
|
*/
|
2012-04-21 01:37:34 +02:00
|
|
|
class CRPCTable
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::map<std::string, const CRPCCommand*> mapCommands;
|
|
|
|
public:
|
|
|
|
CRPCTable();
|
2015-05-31 15:36:44 +02:00
|
|
|
const CRPCCommand* operator[](const std::string& name) const;
|
|
|
|
std::string help(const std::string& name) const;
|
2012-04-09 21:07:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute a method.
|
|
|
|
* @param method Method to execute
|
2015-05-13 21:29:19 +02:00
|
|
|
* @param params UniValue Array of arguments (JSON objects)
|
2012-04-09 21:07:25 +02:00
|
|
|
* @returns Result of the call.
|
2015-05-13 21:29:19 +02:00
|
|
|
* @throws an exception (UniValue) when an error happens.
|
2012-04-09 21:07:25 +02:00
|
|
|
*/
|
2015-05-13 21:29:19 +02:00
|
|
|
UniValue execute(const std::string &method, const UniValue ¶ms) const;
|
2016-02-27 04:57:12 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of registered commands
|
|
|
|
* @returns List of registered commands.
|
|
|
|
*/
|
|
|
|
std::vector<std::string> listCommands() const;
|
2012-04-21 01:37:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const CRPCTable tableRPC;
|
2013-05-30 15:51:41 +02:00
|
|
|
|
2014-10-30 03:14:08 +01:00
|
|
|
/**
|
|
|
|
* Utilities: convert hex-encoded Values
|
|
|
|
* (throws error if not hex).
|
|
|
|
*/
|
2015-05-13 21:29:19 +02:00
|
|
|
extern uint256 ParseHashV(const UniValue& v, std::string strName);
|
|
|
|
extern uint256 ParseHashO(const UniValue& o, std::string strKey);
|
|
|
|
extern std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strName);
|
|
|
|
extern std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey);
|
2012-04-21 01:37:34 +02:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
extern int64_t nWalletUnlockTime;
|
2015-05-13 21:29:19 +02:00
|
|
|
extern CAmount AmountFromValue(const UniValue& value);
|
|
|
|
extern UniValue ValueFromAmount(const CAmount& amount);
|
2012-08-21 17:03:38 +02:00
|
|
|
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
|
|
|
|
extern std::string HelpRequiringPassphrase();
|
2015-05-31 15:36:44 +02:00
|
|
|
extern std::string HelpExampleCli(const std::string& methodname, const std::string& args);
|
|
|
|
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
|
2013-10-29 12:29:44 +01:00
|
|
|
|
2012-08-21 17:03:38 +02:00
|
|
|
extern void EnsureWalletIsUnlocked();
|
2012-08-21 16:38:57 +02:00
|
|
|
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue getconnectioncount(const UniValue& params, bool fHelp); // in rpcnet.cpp
|
|
|
|
extern UniValue getpeerinfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue ping(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue addnode(const UniValue& params, bool fHelp);
|
2015-06-12 05:20:54 +02:00
|
|
|
extern UniValue disconnectnode(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue getaddednodeinfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getnettotals(const UniValue& params, bool fHelp);
|
2015-06-12 18:31:47 +02:00
|
|
|
extern UniValue setban(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listbanned(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue clearbanned(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
|
|
|
|
extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp
|
|
|
|
extern UniValue importprivkey(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue importaddress(const UniValue& params, bool fHelp);
|
2015-07-10 07:47:36 +02:00
|
|
|
extern UniValue importpubkey(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue dumpwallet(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue importwallet(const UniValue& params, bool fHelp);
|
|
|
|
|
|
|
|
extern UniValue getgenerate(const UniValue& params, bool fHelp); // in rpcmining.cpp
|
|
|
|
extern UniValue setgenerate(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue generate(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getnetworkhashps(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getmininginfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue prioritisetransaction(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getblocktemplate(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue submitblock(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue estimatefee(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue estimatepriority(const UniValue& params, bool fHelp);
|
2015-11-16 21:26:57 +01:00
|
|
|
extern UniValue estimatesmartfee(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue estimatesmartpriority(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
|
2016-02-02 16:28:56 +01:00
|
|
|
extern UniValue sendtoaddressix(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue keepass(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp
|
|
|
|
extern UniValue getaccountaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getrawchangeaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue setaccount(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getaccount(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getaddressesbyaccount(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue sendtoaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue signmessage(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue verifymessage(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getbalance(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue movecmd(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue sendfrom(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue sendmany(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue addmultisigaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue createmultisig(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listreceivedbyaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listreceivedbyaccount(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listtransactions(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listaddressgroupings(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listaccounts(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listsinceblock(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue gettransaction(const UniValue& params, bool fHelp);
|
2016-01-07 22:31:12 +01:00
|
|
|
extern UniValue abandontransaction(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue backupwallet(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue keypoolrefill(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue walletpassphrase(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue walletpassphrasechange(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue walletlock(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue encryptwallet(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue validateaddress(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getinfo(const UniValue& params, bool fHelp);
|
2016-03-14 23:56:55 +01:00
|
|
|
extern UniValue debug(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue getwalletinfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getblockchaininfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getnetworkinfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue setmocktime(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue resendwallettransactions(const UniValue& params, bool fHelp);
|
|
|
|
|
|
|
|
extern UniValue getrawtransaction(const UniValue& params, bool fHelp); // in rcprawtransaction.cpp
|
|
|
|
extern UniValue listunspent(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue lockunspent(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue listlockunspent(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue createrawtransaction(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue decoderawtransaction(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue decodescript(const UniValue& params, bool fHelp);
|
2015-04-25 03:27:30 +02:00
|
|
|
extern UniValue fundrawtransaction(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue gettxoutproof(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue verifytxoutproof(const UniValue& params, bool fHelp);
|
|
|
|
|
2016-02-02 16:28:56 +01:00
|
|
|
extern UniValue darksend(const UniValue& params, bool fHelp);
|
2016-03-06 17:44:21 +01:00
|
|
|
extern UniValue getpoolinfo(const UniValue& params, bool fHelp);
|
2016-02-02 16:28:56 +01:00
|
|
|
extern UniValue spork(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue masternode(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue masternodelist(const UniValue& params, bool fHelp);
|
2016-03-16 16:30:22 +01:00
|
|
|
extern UniValue masternodebroadcast(const UniValue& params, bool fHelp);
|
2016-04-19 18:51:15 +02:00
|
|
|
extern UniValue mngovernance(const UniValue& params, bool fHelp);
|
2016-05-05 19:44:46 +02:00
|
|
|
extern UniValue voteraw(const UniValue& params, bool fHelp);
|
2016-02-02 16:28:56 +01:00
|
|
|
extern UniValue mnsync(const UniValue& params, bool fHelp);
|
2016-03-06 17:44:21 +01:00
|
|
|
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue getblockcount(const UniValue& params, bool fHelp); // in rpcblockchain.cpp
|
|
|
|
extern UniValue getbestblockhash(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getdifficulty(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue settxfee(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getmempoolinfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getrawmempool(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getblockhash(const UniValue& params, bool fHelp);
|
2015-06-05 21:37:17 +02:00
|
|
|
extern UniValue getblockheader(const UniValue& params, bool fHelp);
|
2015-05-13 21:29:19 +02:00
|
|
|
extern UniValue getblock(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue gettxout(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue verifychain(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue getchaintips(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue invalidateblock(const UniValue& params, bool fHelp);
|
|
|
|
extern UniValue reconsiderblock(const UniValue& params, bool fHelp);
|
2012-08-21 17:03:38 +02:00
|
|
|
|
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.
- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.
- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral
- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.
- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.
By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.
What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.
Configuration options:
- `-rpcthreads`: repurposed as "number of work handler threads". Still
defaults to 4.
- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.
- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.
- `-debug=http`: low-level http activity logging
2015-01-23 07:53:17 +01:00
|
|
|
bool StartRPC();
|
|
|
|
void InterruptRPC();
|
|
|
|
void StopRPC();
|
|
|
|
std::string JSONRPCExecBatch(const UniValue& vReq);
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_RPCSERVER_H
|