Skip to content

Commit faddce8

Browse files
MarcoFalkeUdjinM6
MarcoFalke
authored andcommitted
Merge bitcoin#13441: Prevent shared conf files from failing with different available options in different binaries
c2dfbb4 Add unavailable options to hidden options category (Andrew Chow) Pull request description: From IRC: ``` <ossifrage> FYI, bitcoin-qt from the head I built today won't start if you have "daemon=0" in the config file, so you can't use the same config for either bitcoind or bitcoin-qt <ossifrage> Seems like bitcoin-qt should ignore this option? <provoostenator> ossifrage: probably caused by 13112. Another problem is disablewallet=1 will prevent a launch if you compile bitcoind without wallet. It probably needs to be relaxed slightly. ``` Adds all of the options that are unavailable due to compiling options to the hidden category so that shared config files do not break with the alternative binaries. Tree-SHA512: 1ef43f5f7ad46ecc2865d22ee683ef22831e8f131ec99b732bb36d90381f7964bf64829595e993c2d435823fe4425a20323c8e65307cf2463a9e40b8049ab559
1 parent d79c82a commit faddce8

File tree

6 files changed

+79
-19
lines changed

6 files changed

+79
-19
lines changed

src/dashd.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ static bool AppInit(int argc, char* argv[])
6565
//
6666
// If Qt is used, parameters/dash.conf are parsed in qt/dash.cpp's main()
6767
SetupServerArgs();
68-
#if HAVE_DECL_DAEMON
69-
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
70-
#endif
7168
std::string error;
7269
if (!gArgs.ParseParameters(argc, argv, error)) {
7370
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());

src/init.cpp

+64-13
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ std::unique_ptr<PeerLogicValidation> peerLogic;
108108
class DummyWalletInit : public WalletInitInterface {
109109
public:
110110

111-
void AddWalletOptions() const override {}
111+
void AddWalletOptions() const override;
112112
bool ParameterInteraction() const override {return true;}
113113
void RegisterRPC(CRPCTable &) const override {}
114114
bool Verify() const override {return true;}
@@ -125,6 +125,21 @@ class DummyWalletInit : public WalletInitInterface {
125125
bool InitAutoBackup() const override {return true;}
126126
};
127127

128+
void DummyWalletInit::AddWalletOptions() const
129+
{
130+
std::vector<std::string> opts = {"-createwalletbackups=<n>", "-disablewallet", "-instantsendnotify=<cmd>",
131+
"-keypool=<n>", "-rescan=<mode>", "-salvagewallet", "-spendzeroconfchange", "-upgradewallet",
132+
"-wallet=<path>", "-walletbackupsdir=<dir>", "-walletbroadcast", "-walletdir=<dir>",
133+
"-walletnotify=<cmd>", "-zapwallettxes=<mode>", "-discardfee=<amt>", "-fallbackfee=<amt>",
134+
"-mintxfee=<amt>", "-paytxfee=<amt>", "-txconfirmtarget=<n>", "-hdseed=<hex>", "-mnemonic=<text>",
135+
"-mnemonicpassphrase=<text>", "-usehd", "-keepass", "-keepassid=<id>", "-keepasskey=<key>",
136+
"-keepassname=<name>", "-keepassport=<port>", "-enablecoinjoin", "-coinjoinamount=<n>",
137+
"-coinjoinautostart", "-coinjoindenomsgoal=<n>", "-coinjoindenomshardcap=<n>", "-coinjoinmultisession",
138+
"-coinjoinrounds=<n>", "-coinjoinsessions=<n>", "-dblogsize=<n>", "-flushwallet", "-privdb",
139+
"-walletrejectlongchains"};
140+
gArgs.AddHiddenArgs(opts);
141+
}
142+
128143
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
129144
#endif
130145

@@ -474,6 +489,12 @@ void SetupServerArgs()
474489

475490
const auto regtestLLMQ = CreateChainParams(CBaseChainParams::REGTEST)->GetConsensus().llmqs.at(Consensus::LLMQ_TEST);
476491

492+
// Hidden Options
493+
std::vector<std::string> hidden_args = {"-rpcssl", "-benchmark", "-h", "-help", "-socks", "-tor", "-debugnet", "-whitelistalwaysrelay",
494+
"-blockminsize", "-dbcrashratio", "-forcecompactdb",
495+
// GUI args. These will be overwritten by SetupUIArgs for the GUI
496+
"-allowselfsignedrootcertificates", "-choosedatadir", "-lang=<lang>", "-min", "-resetguisettings", "-rootcertificates=<file>", "-splash", "-uiplatform"};
497+
477498

478499
// Set all of the args and their help
479500
// When adding new options to the categories, please keep and ensure alphabetical ordering.
@@ -501,13 +522,17 @@ void SetupServerArgs()
501522
gArgs.AddArg("-persistmempool", strprintf("Whether to save the mempool on shutdown and load on restart (default: %u)", DEFAULT_PERSIST_MEMPOOL), false, OptionsCategory::OPTIONS);
502523
#ifndef WIN32
503524
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);
525+
#else
526+
hidden_args.emplace_back("-pid");
504527
#endif
505528
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, -rescan and -disablegovernance=false. "
506529
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
507530
"(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >%u = automatically prune block files to stay under the specified target size in MiB)", MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024), false, OptionsCategory::OPTIONS);
508531
gArgs.AddArg("-syncmempool", strprintf("Sync mempool from other nodes on start (default: %u)", DEFAULT_SYNC_MEMPOOL), false, OptionsCategory::OPTIONS);
509532
#ifndef WIN32
510533
gArgs.AddArg("-sysperms", "Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)", false, OptionsCategory::OPTIONS);
534+
#else
535+
hidden_args.emplace_back("-sysperms");
511536
#endif
512537
gArgs.AddArg("-version", "Print version and exit", false, OptionsCategory::OPTIONS);
513538

@@ -557,6 +582,8 @@ void SetupServerArgs()
557582
#else
558583
gArgs.AddArg("-upnp", strprintf("Use UPnP to map the listening port (default: %u)", 0), false, OptionsCategory::CONNECTION);
559584
#endif
585+
#else
586+
hidden_args.emplace_back("-upnp");
560587
#endif
561588
gArgs.AddArg("-whitebind=<addr>", "Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6", false, OptionsCategory::CONNECTION);
562589
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."
@@ -566,17 +593,42 @@ void SetupServerArgs()
566593

567594
#if ENABLE_ZMQ
568595
gArgs.AddArg("-zmqpubhashblock=<address>", "Enable publish hash block in <address>", false, OptionsCategory::ZMQ);
596+
gArgs.AddArg("-zmqpubhashchainlock=<address>", "Enable publish hash block (locked via ChainLocks) in <address>", false, OptionsCategory::ZMQ);
569597
gArgs.AddArg("-zmqpubhashgovernanceobject=<address>", "Enable publish hash of governance objects (like proposals) in <address>", false, OptionsCategory::ZMQ);
570598
gArgs.AddArg("-zmqpubhashgovernancevote=<address>", "Enable publish hash of governance votes in <address>", false, OptionsCategory::ZMQ);
571599
gArgs.AddArg("-zmqpubhashinstantsenddoublespend=<address>", "Enable publish transaction hashes of attempted InstantSend double spend in <address>", false, OptionsCategory::ZMQ);
572600
gArgs.AddArg("-zmqpubhashrecoveredsig=<address>", "Enable publish message hash of recovered signatures (recovered by LLMQs) in <address>", false, OptionsCategory::ZMQ);
573601
gArgs.AddArg("-zmqpubhashtx=<address>", "Enable publish hash transaction in <address>", false, OptionsCategory::ZMQ);
574602
gArgs.AddArg("-zmqpubhashtxlock=<address>", "Enable publish hash transaction (locked via InstantSend) in <address>", false, OptionsCategory::ZMQ);
575603
gArgs.AddArg("-zmqpubrawblock=<address>", "Enable publish raw block in <address>", false, OptionsCategory::ZMQ);
604+
gArgs.AddArg("-zmqpubrawchainlock=<address>", "Enable publish raw block (locked via ChainLocks) in <address>", false, OptionsCategory::ZMQ);
605+
gArgs.AddArg("-zmqpubrawchainlocksig=<address>", "Enable publish raw block (locked via ChainLocks) and CLSIG message in <address>", false, OptionsCategory::ZMQ);
606+
gArgs.AddArg("-zmqpubrawgovernancevote=<address>", "Enable publish raw governance objects (like proposals) in <address>", false, OptionsCategory::ZMQ);
607+
gArgs.AddArg("-zmqpubrawgovernanceobject=<address>", "Enable publish raw governance votes in <address>", false, OptionsCategory::ZMQ);
576608
gArgs.AddArg("-zmqpubrawinstantsenddoublespend=<address>", "Enable publish raw transactions of attempted InstantSend double spend in <address>", false, OptionsCategory::ZMQ);
577609
gArgs.AddArg("-zmqpubrawrecoveredsig=<address>", "Enable publish raw recovered signatures (recovered by LLMQs) in <address>", false, OptionsCategory::ZMQ);
578610
gArgs.AddArg("-zmqpubrawtx=<address>", "Enable publish raw transaction in <address>", false, OptionsCategory::ZMQ);
579611
gArgs.AddArg("-zmqpubrawtxlock=<address>", "Enable publish raw transaction (locked via InstantSend) in <address>", false, OptionsCategory::ZMQ);
612+
gArgs.AddArg("-zmqpubrawtxlocksig=<address>", "Enable publish raw transaction (locked via InstantSend) and ISLOCK in <address>", false, OptionsCategory::ZMQ);
613+
#else
614+
hidden_args.emplace_back("-zmqpubhashblock=<address>");
615+
hidden_args.emplace_back("-zmqpubhashchainlock=<address>");
616+
hidden_args.emplace_back("-zmqpubhashgovernanceobject=<address>");
617+
hidden_args.emplace_back("-zmqpubhashgovernancevote=<address>");
618+
hidden_args.emplace_back("-zmqpubhashinstantsenddoublespend=<address>");
619+
hidden_args.emplace_back("-zmqpubhashrecoveredsig=<address>");
620+
hidden_args.emplace_back("-zmqpubhashtx=<address>");
621+
hidden_args.emplace_back("-zmqpubhashtxlock=<address>");
622+
hidden_args.emplace_back("-zmqpubrawblock=<address>");
623+
hidden_args.emplace_back("-zmqpubrawchainlock=<address>");
624+
hidden_args.emplace_back("-zmqpubrawchainlocksig=<address>");
625+
hidden_args.emplace_back("-zmqpubrawgovernancevote=<address>");
626+
hidden_args.emplace_back("-zmqpubrawgovernanceobject=<address>");
627+
hidden_args.emplace_back("-zmqpubrawinstantsenddoublespend=<address>");
628+
hidden_args.emplace_back("-zmqpubrawrecoveredsig=<address>");
629+
hidden_args.emplace_back("-zmqpubrawtx=<address>");
630+
hidden_args.emplace_back("-zmqpubrawtxlock=<address>");
631+
hidden_args.emplace_back("-zmqpubrawtxlocksig=<address>");
580632
#endif
581633

582634
gArgs.AddArg("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. (default: %u)", defaultChainParams->DefaultConsistencyChecks()), true, OptionsCategory::DEBUG_TEST);
@@ -596,9 +648,12 @@ void SetupServerArgs()
596648
gArgs.AddArg("-watchquorums=<n>", strprintf("Watch and validate quorum communication (default: %u)", llmq::DEFAULT_WATCH_QUORUMS), true, OptionsCategory::DEBUG_TEST);
597649
gArgs.AddArg("-addrmantest", "Allows to test address relay on localhost", true, OptionsCategory::DEBUG_TEST);
598650

651+
gArgs.AddArg("-budgetparams=<masternode>:<budget>:<superblock>", "Override masternode, budget and superblock start heights", false, OptionsCategory::DEBUG_TEST);
599652
gArgs.AddArg("-debug=<category>", strprintf("Output debugging information (default: %u, supplying <category> is optional)", 0) + ". " +
600653
"If <category> is not supplied or if <category> = 1, output all debugging information. <category> can be: " + ListLogCategories() + ".", false, OptionsCategory::DEBUG_TEST);
601654
gArgs.AddArg("-debugexclude=<category>", strprintf("Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories."), false, OptionsCategory::DEBUG_TEST);
655+
gArgs.AddArg("-dip3params=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights", false, OptionsCategory::DEBUG_TEST);
656+
gArgs.AddArg("-dip8params=<activation>", "Override DIP8 activation height", false, OptionsCategory::DEBUG_TEST);
602657
gArgs.AddArg("-disablegovernance", strprintf("Disable governance validation (0-1, default: %u)", 0), false, OptionsCategory::DEBUG_TEST);
603658
gArgs.AddArg("-help-debug", "Show all debugging options (usage: --help -help-debug)", false, OptionsCategory::DEBUG_TEST);
604659
gArgs.AddArg("-highsubsidyblocks=<n>", strprintf("The number of blocks with a higher than normal subsidy to mine at the start of a devnet (default: %u)", devnetConsensus.nHighSubsidyBlocks), false, OptionsCategory::DEBUG_TEST);
@@ -620,6 +675,7 @@ void SetupServerArgs()
620675
gArgs.AddArg("-minsporkkeys=<n>", "Overrides minimum spork signers to change spork value. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.", false, OptionsCategory::DEBUG_TEST);
621676
gArgs.AddArg("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY), true, OptionsCategory::DEBUG_TEST);
622677
gArgs.AddArg("-printtoconsole", "Send trace/debug info to console instead of debug.log file", false, OptionsCategory::DEBUG_TEST);
678+
gArgs.AddArg("-pushversion", "Protocol version to report to other nodes", false, OptionsCategory::DEBUG_TEST);
623679
gArgs.AddArg("-shrinkdebugfile", "Shrink debug.log file on client startup (default: 1 when no -debug)", false, OptionsCategory::DEBUG_TEST);
624680
gArgs.AddArg("-sporkaddr=<dashaddress>", "Override spork address. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.", false, OptionsCategory::DEBUG_TEST);
625681
gArgs.AddArg("-sporkkey=<privatekey>", "Set the private key to be used for signing spork messages.", false, OptionsCategory::DEBUG_TEST);
@@ -666,19 +722,14 @@ void SetupServerArgs()
666722
gArgs.AddArg("-statsport=<port>", strprintf("Specify statsd port (default: %u)", DEFAULT_STATSD_PORT), false, OptionsCategory::STATSD);
667723
gArgs.AddArg("-statsns=<ns>", strprintf("Specify additional namespace prefix (default: %s)", DEFAULT_STATSD_NAMESPACE), false, OptionsCategory::STATSD);
668724
gArgs.AddArg("-statsperiod=<seconds>", strprintf("Specify the number of seconds between periodic measurements (default: %d)", DEFAULT_STATSD_PERIOD), false, OptionsCategory::STATSD);
725+
#if HAVE_DECL_DAEMON
726+
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
727+
#else
728+
hidden_args.emplace_back("-daemon");
729+
#endif
669730

670-
// Hidden options
671-
gArgs.AddArg("-benchmark", "", false, OptionsCategory::HIDDEN);
672-
gArgs.AddArg("-blockminsize", "", false, OptionsCategory::HIDDEN);
673-
gArgs.AddArg("-dbcrashratio", "", false, OptionsCategory::HIDDEN);
674-
gArgs.AddArg("-debugnet", "", false, OptionsCategory::HIDDEN);
675-
gArgs.AddArg("-forcecompactdb", "", false, OptionsCategory::HIDDEN);
676-
gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN);
677-
gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN);
678-
gArgs.AddArg("-rpcssl", "", false, OptionsCategory::HIDDEN);
679-
gArgs.AddArg("-socks", "", false, OptionsCategory::HIDDEN);
680-
gArgs.AddArg("-tor", "", false, OptionsCategory::HIDDEN);
681-
gArgs.AddArg("-whitelistalwaysrelay", "", false, OptionsCategory::HIDDEN);
731+
// Add the hidden options
732+
gArgs.AddHiddenArgs(hidden_args);
682733
}
683734

684735
std::string LicenseInfo()

src/util.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,13 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
593593
assert(ret.second); // Make sure an insertion actually happened
594594
}
595595

596+
void ArgsManager::AddHiddenArgs(const std::vector<std::string>& names)
597+
{
598+
for (const std::string& name : names) {
599+
AddArg(name, "", false, OptionsCategory::HIDDEN);
600+
}
601+
}
602+
596603
std::string ArgsManager::GetHelpMessage()
597604
{
598605
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);

src/util.h

+5
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ class ArgsManager
301301
*/
302302
void AddArg(const std::string& name, const std::string& help, const bool debug_only, const OptionsCategory& cat);
303303

304+
/**
305+
* Add many hidden arguments
306+
*/
307+
void AddHiddenArgs(const std::vector<std::string>& args);
308+
304309
/**
305310
* Clear available arguments
306311
*/

test/functional/feature_addressindex.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def set_test_params(self):
2323
def setup_network(self):
2424
self.add_nodes(self.num_nodes)
2525
# Nodes 0/1 are "wallet" nodes
26-
self.start_node(0, ["-relaypriority=0"])
26+
self.start_node(0, [])
2727
self.start_node(1, ["-addressindex"])
2828
# Nodes 2/3 are used for testing
29-
self.start_node(2, ["-addressindex", "-relaypriority=0"])
29+
self.start_node(2, ["-addressindex"])
3030
self.start_node(3, ["-addressindex"])
3131
connect_nodes(self.nodes[0], 1)
3232
connect_nodes(self.nodes[0], 2)

test/functional/wallet_keypool_topup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class KeypoolRestoreTest(BitcoinTestFramework):
2424
def set_test_params(self):
2525
self.setup_clean_chain = True
2626
self.num_nodes = 2
27-
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=100', '-keypoolmin=20']]
27+
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=100']]
2828

2929
def run_test(self):
3030
wallet_path = os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat")

0 commit comments

Comments
 (0)