You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/bitcoin-cli.cpp
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@
11
11
#include<clientversion.h>
12
12
#include<optional.h>
13
13
#include<rpc/client.h>
14
+
#include<rpc/mining.h>
14
15
#include<rpc/protocol.h>
15
16
#include<rpc/request.h>
16
17
#include<util/strencodings.h>
@@ -39,6 +40,9 @@ static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
39
40
staticconstbool DEFAULT_NAMED=false;
40
41
staticconstint CONTINUE_EXECUTION=-1;
41
42
43
+
/** Default number of blocks to generate for RPC generatetoaddress. */
44
+
staticconst std::string DEFAULT_NBLOCKS = "1";
45
+
42
46
staticvoidSetupCliArgs()
43
47
{
44
48
SetupHelpOptions(gArgs);
@@ -50,6 +54,7 @@ static void SetupCliArgs()
50
54
gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
51
55
gArgs.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
52
56
gArgs.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
57
+
gArgs.AddArg("-generate", strprintf("Generate blocks immediately, equivalent to RPC generatenewaddress followed by RPC generatetoaddress. Optional positional integer arguments are number of blocks to generate (default: %s) and maximum iterations to try (default: %s), equivalent to RPC generatetoaddress nblocks and maxtries arguments. Example: bitcoin-cli -generate 4 1000", DEFAULT_NBLOCKS, DEFAULT_MAX_TRIES), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
53
58
gArgs.AddArg("-getinfo", "Get general information from the remote server. Note that unlike server-side RPC calls, the results of -getinfo is the result of multiple non-atomic requests. Some entries in the result may represent results from different states (e.g. wallet balance may be as of a different block from the chain state reported)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
54
59
SetupChainParamsBaseOptions();
55
60
gArgs.AddArg("-named", strprintf("Pass named instead of positional arguments (default: %s)", DEFAULT_NAMED), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
if (args.size() > 2) throwstd::runtime_error("too many arguments (maximum 2 for nblocks and maxtries)");
553
+
if (args.size() == 0) {
554
+
args.emplace_back(DEFAULT_NBLOCKS);
555
+
} elseif (args.at(0) == "0") {
556
+
throwstd::runtime_error("the first argument (number of blocks to generate, default: " + DEFAULT_NBLOCKS + ") must be an integer value greater than zero");
557
+
}
558
+
args.emplace(args.begin() + 1, address);
559
+
}
560
+
540
561
staticintCommandLineRPC(int argc, char *argv[])
541
562
{
542
563
std::string strPrint;
@@ -595,6 +616,15 @@ static int CommandLineRPC(int argc, char *argv[])
0 commit comments