Bitcoin Core 28.99.0
P2P Digital Currency
|
#include <bitcoin-build-config.h>
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/args.h>
#include <common/system.h>
#include <compat/compat.h>
#include <compat/stdin.h>
#include <policy/feerate.h>
#include <rpc/client.h>
#include <rpc/mining.h>
#include <rpc/protocol.h>
#include <rpc/request.h>
#include <tinyformat.h>
#include <univalue.h>
#include <util/chaintype.h>
#include <util/exception.h>
#include <util/strencodings.h>
#include <util/time.h>
#include <util/translation.h>
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <unistd.h>
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
#include <support/events.h>
Go to the source code of this file.
Classes | |
class | CConnectionFailed |
struct | HTTPReply |
Reply structure for request_done to fill in. More... | |
class | BaseRequestHandler |
Class that handles the conversion from a command-line to a JSON-RPC request, as well as converting back to a JSON object that can be shown as result. More... | |
class | AddrinfoRequestHandler |
Process addrinfo requests. More... | |
class | GetinfoRequestHandler |
Process getinfo requests. More... | |
class | NetinfoRequestHandler |
Process netinfo requests. More... | |
struct | NetinfoRequestHandler::Peer |
class | GenerateToAddressRequestHandler |
Process RPC generatetoaddress request. More... | |
class | DefaultRequestHandler |
Process default single requests. More... | |
Typedefs | |
using | CliClock = std::chrono::system_clock |
Functions | |
static void | SetupCliArgs (ArgsManager &argsman) |
static void | libevent_log_cb (int severity, const char *msg) |
libevent event log callback More... | |
static int | AppInitRPC (int argc, char *argv[]) |
static std::string | http_errorstring (int code) |
static void | http_request_done (struct evhttp_request *req, void *ctx) |
static void | http_error_cb (enum evhttp_request_error err, void *ctx) |
static UniValue | CallRPC (BaseRequestHandler *rh, const std::string &strMethod, const std::vector< std::string > &args, const std::optional< std::string > &rpcwallet={}) |
static UniValue | ConnectAndCallRPC (BaseRequestHandler *rh, const std::string &strMethod, const std::vector< std::string > &args, const std::optional< std::string > &rpcwallet={}) |
ConnectAndCallRPC wraps CallRPC with -rpcwait and an exception handler. More... | |
static void | ParseResult (const UniValue &result, std::string &strPrint) |
Parse UniValue result to update the message to print to std::cout. More... | |
static void | ParseError (const UniValue &error, std::string &strPrint, int &nRet) |
Parse UniValue error to update the message to print to std::cerr and the code to return. More... | |
static void | GetWalletBalances (UniValue &result) |
GetWalletBalances calls listwallets; if more than one wallet is loaded, it then fetches mine.trusted balances for each loaded wallet and pushes them to result . More... | |
static void | GetProgressBar (double progress, std::string &progress_bar) |
GetProgressBar constructs a progress bar with 5% intervals. More... | |
static void | ParseGetInfoResult (UniValue &result) |
ParseGetInfoResult takes in -getinfo result in UniValue object and parses it into a user friendly UniValue string to be printed on the console. More... | |
static UniValue | GetNewAddress () |
Call RPC getnewaddress. More... | |
static void | SetGenerateToAddressArgs (const std::string &address, std::vector< std::string > &args) |
Check bounds and set up args for RPC generatetoaddress params: nblocks, address, maxtries. More... | |
static int | CommandLineRPC (int argc, char *argv[]) |
if (!SetupNetworking()) | |
if (ret !=CONTINUE_EXECUTION) return ret | |
catch (const std::exception &e) | |
catch (...) | |
Variables | |
const std::function< std::string(const char *)> | G_TRANSLATION_FUN = nullptr |
Translate string to current locale using Qt. More... | |
static const char | DEFAULT_RPCCONNECT [] = "127.0.0.1" |
static const int | DEFAULT_HTTP_CLIENT_TIMEOUT =900 |
static constexpr int | DEFAULT_WAIT_CLIENT_TIMEOUT = 0 |
static const bool | DEFAULT_NAMED =false |
static const int | CONTINUE_EXECUTION =-1 |
static constexpr uint8_t | NETINFO_MAX_LEVEL {4} |
static constexpr int8_t | UNKNOWN_NETWORK {-1} |
static constexpr std::array | NETWORKS {"not_publicly_routable", "ipv4", "ipv6", "onion", "i2p", "cjdns", "internal"} |
static constexpr std::array | NETWORK_SHORT_NAMES {"npr", "ipv4", "ipv6", "onion", "i2p", "cjdns", "int"} |
static constexpr std::array | UNREACHABLE_NETWORK_IDS {0, 6} |
static const std::string | DEFAULT_NBLOCKS = "1" |
Default number of blocks to generate for RPC generatetoaddress. More... | |
static const std::string | DEFAULT_COLOR_SETTING {"auto"} |
Default -color setting. More... | |
MAIN_FUNCTION | |
event_set_log_callback & | libevent_log_cb |
try | |
int | ret = EXIT_FAILURE |
using CliClock = std::chrono::system_clock |
Definition at line 51 of file bitcoin-cli.cpp.
|
static |
|
static |
catch | ( | ... | ) |
Definition at line 1349 of file bitcoin-cli.cpp.
catch | ( | const std::exception & | e | ) |
Definition at line 1346 of file bitcoin-cli.cpp.
|
static |
|
static |
ConnectAndCallRPC wraps CallRPC with -rpcwait and an exception handler.
[in] | rh | Pointer to RequestHandler. |
[in] | strMethod | Reference to const string method to forward to CallRPC. |
[in] | rpcwallet | Reference to const optional string wallet name to forward to CallRPC. |
a | CConnectionFailed std::runtime_error if connection failed or RPC server still in warmup. |
Definition at line 950 of file bitcoin-cli.cpp.
|
static |
Call RPC getnewaddress.
Definition at line 1184 of file bitcoin-cli.cpp.
|
static |
GetProgressBar constructs a progress bar with 5% intervals.
[in] | progress | The proportion of the progress bar to be filled between 0 and 1. |
[out] | progress_bar | String representation of the progress bar. |
Definition at line 1038 of file bitcoin-cli.cpp.
|
static |
GetWalletBalances calls listwallets; if more than one wallet is loaded, it then fetches mine.trusted balances for each loaded wallet and pushes them to result
.
result | Reference to UniValue object the wallet names and balances are pushed to. |
Definition at line 1014 of file bitcoin-cli.cpp.
|
static |
Definition at line 249 of file bitcoin-cli.cpp.
|
static |
Definition at line 204 of file bitcoin-cli.cpp.
|
static |
Definition at line 224 of file bitcoin-cli.cpp.
if | ( | ! | SetupNetworking() | ) |
Definition at line 1335 of file bitcoin-cli.cpp.
if | ( | ret ! | = CONTINUE_EXECUTION | ) |
Definition at line 159 of file bitcoin-util.cpp.
|
static |
libevent event log callback
Definition at line 114 of file bitcoin-cli.cpp.
|
static |
Parse UniValue error to update the message to print to std::cerr and the code to return.
Definition at line 987 of file bitcoin-cli.cpp.
|
static |
ParseGetInfoResult takes in -getinfo result in UniValue object and parses it into a user friendly UniValue string to be printed on the console.
[out] | result | Reference to UniValue result containing the -getinfo output. |
Definition at line 1060 of file bitcoin-cli.cpp.
|
static |
Parse UniValue result to update the message to print to std::cout.
Definition at line 980 of file bitcoin-cli.cpp.
|
static |
Check bounds and set up args for RPC generatetoaddress params: nblocks, address, maxtries.
[in] | address | Reference to const string address to insert into the args. |
args | Reference to vector of string args to modify. |
Definition at line 1197 of file bitcoin-cli.cpp.
|
static |
Definition at line 73 of file bitcoin-cli.cpp.
|
static |
Definition at line 59 of file bitcoin-cli.cpp.
|
static |
Default -color setting.
Definition at line 71 of file bitcoin-cli.cpp.
|
static |
Definition at line 56 of file bitcoin-cli.cpp.
|
static |
Definition at line 58 of file bitcoin-cli.cpp.
|
static |
Default number of blocks to generate for RPC generatetoaddress.
Definition at line 68 of file bitcoin-cli.cpp.
|
static |
Definition at line 55 of file bitcoin-cli.cpp.
|
staticconstexpr |
Definition at line 57 of file bitcoin-cli.cpp.
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr |
Translate string to current locale using Qt.
Translate a message to the native language of the user.
Definition at line 53 of file bitcoin-cli.cpp.
event_set_log_callback& libevent_log_cb |
Definition at line 1339 of file bitcoin-cli.cpp.
MAIN_FUNCTION |
Definition at line 1328 of file bitcoin-cli.cpp.
|
staticconstexpr |
Definition at line 60 of file bitcoin-cli.cpp.
|
staticconstexpr |
Definition at line 64 of file bitcoin-cli.cpp.
|
staticconstexpr |
Definition at line 63 of file bitcoin-cli.cpp.
return ret = EXIT_FAILURE |
Definition at line 1354 of file bitcoin-cli.cpp.
try |
Definition at line 1341 of file bitcoin-cli.cpp.
|
staticconstexpr |
Definition at line 61 of file bitcoin-cli.cpp.
|
staticconstexpr |
Definition at line 65 of file bitcoin-cli.cpp.