Add unavailable options to hidden options category
Options that are not available (but known in the source code) will cause an error if they are specified. Make these options "available" by adding them to the hidden options category to prevent conf files from failing when shared between binaries that have different options available.
This commit is contained in:
parent
7c32b414b6
commit
c2dfbb4a97
4 changed files with 47 additions and 20 deletions
|
@ -62,9 +62,6 @@ static bool AppInit(int argc, char* argv[])
|
||||||
//
|
//
|
||||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
||||||
SetupServerArgs();
|
SetupServerArgs();
|
||||||
#if HAVE_DECL_DAEMON
|
|
||||||
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
|
|
||||||
#endif
|
|
||||||
std::string error;
|
std::string error;
|
||||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||||
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
|
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||||
|
|
52
src/init.cpp
52
src/init.cpp
|
@ -76,7 +76,7 @@ std::unique_ptr<PeerLogicValidation> peerLogic;
|
||||||
class DummyWalletInit : public WalletInitInterface {
|
class DummyWalletInit : public WalletInitInterface {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void AddWalletOptions() const override {}
|
void AddWalletOptions() const override;
|
||||||
bool ParameterInteraction() const override {return true;}
|
bool ParameterInteraction() const override {return true;}
|
||||||
void RegisterRPC(CRPCTable &) const override {}
|
void RegisterRPC(CRPCTable &) const override {}
|
||||||
bool Verify() const override {return true;}
|
bool Verify() const override {return true;}
|
||||||
|
@ -87,6 +87,15 @@ public:
|
||||||
void Close() const override {}
|
void Close() const override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void DummyWalletInit::AddWalletOptions() const
|
||||||
|
{
|
||||||
|
std::vector<std::string> opts = {"-addresstype", "-changetype", "-disablewallet", "-discardfee=<amt>", "-fallbackfee=<amt>",
|
||||||
|
"-keypool=<n>", "-mintxfee=<amt>", "-paytxfee=<amt>", "-rescan", "-salvagewallet", "-spendzeroconfchange", "-txconfirmtarget=<n>",
|
||||||
|
"-upgradewallet", "-wallet=<path>", "-walletbroadcast", "-walletdir=<dir>", "-walletnotify=<cmd>", "-walletrbf", "-zapwallettxes=<mode>",
|
||||||
|
"-dblogsize=<n>", "-flushwallet", "-privdb", "-walletrejectlongchains"};
|
||||||
|
gArgs.AddHiddenArgs(opts);
|
||||||
|
}
|
||||||
|
|
||||||
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
|
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -348,6 +357,12 @@ void SetupServerArgs()
|
||||||
const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN);
|
const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN);
|
||||||
const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET);
|
const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET);
|
||||||
|
|
||||||
|
// Hidden Options
|
||||||
|
std::vector<std::string> hidden_args = {"-rpcssl", "-benchmark", "-h", "-help", "-socks", "-tor", "-debugnet", "-whitelistalwaysrelay",
|
||||||
|
"-prematurewitness", "-walletprematurewitness", "-promiscuousmempoolflags", "-blockminsize", "-dbcrashratio", "-forcecompactdb", "-usehd",
|
||||||
|
// GUI args. These will be overwritten by SetupUIArgs for the GUI
|
||||||
|
"-allowselfsignedrootcertificates", "-choosedatadir", "-lang=<lang>", "-min", "-resetguisettings", "-rootcertificates=<file>", "-splash", "-uiplatform"};
|
||||||
|
|
||||||
// Set all of the args and their help
|
// Set all of the args and their help
|
||||||
// When adding new options to the categories, please keep and ensure alphabetical ordering.
|
// When adding new options to the categories, please keep and ensure alphabetical ordering.
|
||||||
gArgs.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS);
|
gArgs.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS);
|
||||||
|
@ -375,6 +390,8 @@ void SetupServerArgs()
|
||||||
gArgs.AddArg("-persistmempool", strprintf("Whether to save the mempool on shutdown and load on restart (default: %u)", DEFAULT_PERSIST_MEMPOOL), false, OptionsCategory::OPTIONS);
|
gArgs.AddArg("-persistmempool", strprintf("Whether to save the mempool on shutdown and load on restart (default: %u)", DEFAULT_PERSIST_MEMPOOL), false, OptionsCategory::OPTIONS);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
gArgs.AddArg("-pid=<file>", strprintf("Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: %s)", BITCOIN_PID_FILENAME), false, OptionsCategory::OPTIONS);
|
gArgs.AddArg("-pid=<file>", strprintf("Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: %s)", BITCOIN_PID_FILENAME), false, OptionsCategory::OPTIONS);
|
||||||
|
#else
|
||||||
|
hidden_args.emplace_back("-pid");
|
||||||
#endif
|
#endif
|
||||||
gArgs.AddArg("-prune=<n>", strprintf("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. "
|
gArgs.AddArg("-prune=<n>", strprintf("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. "
|
||||||
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
||||||
|
@ -383,6 +400,8 @@ void SetupServerArgs()
|
||||||
gArgs.AddArg("-reindex-chainstate", "Rebuild chain state from the currently indexed blocks", false, OptionsCategory::OPTIONS);
|
gArgs.AddArg("-reindex-chainstate", "Rebuild chain state from the currently indexed blocks", false, OptionsCategory::OPTIONS);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
gArgs.AddArg("-sysperms", "Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)", false, OptionsCategory::OPTIONS);
|
gArgs.AddArg("-sysperms", "Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)", false, OptionsCategory::OPTIONS);
|
||||||
|
#else
|
||||||
|
hidden_args.emplace_back("-sysperms");
|
||||||
#endif
|
#endif
|
||||||
gArgs.AddArg("-txindex", strprintf("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)", DEFAULT_TXINDEX), false, OptionsCategory::OPTIONS);
|
gArgs.AddArg("-txindex", strprintf("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)", DEFAULT_TXINDEX), false, OptionsCategory::OPTIONS);
|
||||||
|
|
||||||
|
@ -421,6 +440,8 @@ void SetupServerArgs()
|
||||||
#else
|
#else
|
||||||
gArgs.AddArg("-upnp", strprintf("Use UPnP to map the listening port (default: %u)", 0), false, OptionsCategory::CONNECTION);
|
gArgs.AddArg("-upnp", strprintf("Use UPnP to map the listening port (default: %u)", 0), false, OptionsCategory::CONNECTION);
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
hidden_args.emplace_back("-upnp");
|
||||||
#endif
|
#endif
|
||||||
gArgs.AddArg("-whitebind=<addr>", "Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6", false, OptionsCategory::CONNECTION);
|
gArgs.AddArg("-whitebind=<addr>", "Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6", false, OptionsCategory::CONNECTION);
|
||||||
gArgs.AddArg("-whitelist=<IP address or network>", "Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple times."
|
gArgs.AddArg("-whitelist=<IP address or network>", "Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple times."
|
||||||
|
@ -433,6 +454,11 @@ void SetupServerArgs()
|
||||||
gArgs.AddArg("-zmqpubhashtx=<address>", "Enable publish hash transaction in <address>", false, OptionsCategory::ZMQ);
|
gArgs.AddArg("-zmqpubhashtx=<address>", "Enable publish hash transaction in <address>", false, OptionsCategory::ZMQ);
|
||||||
gArgs.AddArg("-zmqpubrawblock=<address>", "Enable publish raw block in <address>", false, OptionsCategory::ZMQ);
|
gArgs.AddArg("-zmqpubrawblock=<address>", "Enable publish raw block in <address>", false, OptionsCategory::ZMQ);
|
||||||
gArgs.AddArg("-zmqpubrawtx=<address>", "Enable publish raw transaction in <address>", false, OptionsCategory::ZMQ);
|
gArgs.AddArg("-zmqpubrawtx=<address>", "Enable publish raw transaction in <address>", false, OptionsCategory::ZMQ);
|
||||||
|
#else
|
||||||
|
hidden_args.emplace_back("-zmqpubhashblock=<address>");
|
||||||
|
hidden_args.emplace_back("-zmqpubhashtx=<address>");
|
||||||
|
hidden_args.emplace_back("-zmqpubrawblock=<address>");
|
||||||
|
hidden_args.emplace_back("-zmqpubrawtx=<address>");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gArgs.AddArg("-checkblocks=<n>", strprintf("How many blocks to check at startup (default: %u, 0 = all)", DEFAULT_CHECKBLOCKS), true, OptionsCategory::DEBUG_TEST);
|
gArgs.AddArg("-checkblocks=<n>", strprintf("How many blocks to check at startup (default: %u, 0 = all)", DEFAULT_CHECKBLOCKS), true, OptionsCategory::DEBUG_TEST);
|
||||||
|
@ -500,22 +526,14 @@ void SetupServerArgs()
|
||||||
gArgs.AddArg("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), true, OptionsCategory::RPC);
|
gArgs.AddArg("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), true, OptionsCategory::RPC);
|
||||||
gArgs.AddArg("-server", "Accept command line and JSON-RPC commands", false, OptionsCategory::RPC);
|
gArgs.AddArg("-server", "Accept command line and JSON-RPC commands", false, OptionsCategory::RPC);
|
||||||
|
|
||||||
// Hidden options
|
#if HAVE_DECL_DAEMON
|
||||||
gArgs.AddArg("-rpcssl", "", false, OptionsCategory::HIDDEN);
|
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
|
||||||
gArgs.AddArg("-benchmark", "", false, OptionsCategory::HIDDEN);
|
#else
|
||||||
gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN);
|
hidden_args.emplace_back("-daemon");
|
||||||
gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN);
|
#endif
|
||||||
gArgs.AddArg("-socks", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-tor", "", false, OptionsCategory::HIDDEN);
|
// Add the hidden options
|
||||||
gArgs.AddArg("-debugnet", "", false, OptionsCategory::HIDDEN);
|
gArgs.AddHiddenArgs(hidden_args);
|
||||||
gArgs.AddArg("-whitelistalwaysrelay", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-prematurewitness", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-walletprematurewitness", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-promiscuousmempoolflags", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-blockminsize", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-dbcrashratio", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-forcecompactdb", "", false, OptionsCategory::HIDDEN);
|
|
||||||
gArgs.AddArg("-usehd", "", false, OptionsCategory::HIDDEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LicenseInfo()
|
std::string LicenseInfo()
|
||||||
|
|
|
@ -585,6 +585,13 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
|
||||||
assert(ret.second); // Make sure an insertion actually happened
|
assert(ret.second); // Make sure an insertion actually happened
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArgsManager::AddHiddenArgs(const std::vector<std::string>& names)
|
||||||
|
{
|
||||||
|
for (const std::string& name : names) {
|
||||||
|
AddArg(name, "", false, OptionsCategory::HIDDEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string ArgsManager::GetHelpMessage()
|
std::string ArgsManager::GetHelpMessage()
|
||||||
{
|
{
|
||||||
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);
|
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);
|
||||||
|
|
|
@ -263,6 +263,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void AddArg(const std::string& name, const std::string& help, const bool debug_only, const OptionsCategory& cat);
|
void AddArg(const std::string& name, const std::string& help, const bool debug_only, const OptionsCategory& cat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add many hidden arguments
|
||||||
|
*/
|
||||||
|
void AddHiddenArgs(const std::vector<std::string>& args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear available arguments
|
* Clear available arguments
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue