Skip to content

Commit 493fb47

Browse files
committed
Make SetupServerArgs callable without NodeContext
bitcoin-gui code needs to call SetupServerArgs but will not have a NodeContext object if it is communicating with an external bitcoin-node process.
1 parent 1704bbf commit 493fb47

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

src/bitcoind.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ static bool AppInit(NodeContext& node, int argc, char* argv[])
112112
util::ThreadSetInternalName("init");
113113

114114
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
115-
SetupServerArgs(node);
116115
ArgsManager& args = *Assert(node.args);
116+
SetupServerArgs(args);
117117
std::string error;
118118
if (!args.ParseParameters(argc, argv, error)) {
119119
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));

src/init.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,8 @@ static void OnRPCStopped()
347347
LogPrint(BCLog::RPC, "RPC stopped.\n");
348348
}
349349

350-
void SetupServerArgs(NodeContext& node)
350+
void SetupServerArgs(ArgsManager& argsman)
351351
{
352-
assert(!node.args);
353-
node.args = &gArgs;
354-
ArgsManager& argsman = *node.args;
355-
356352
SetupHelpOptions(argsman);
357353
argsman.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
358354

src/init.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info
6969
/**
7070
* Register all arguments with the ArgsManager
7171
*/
72-
void SetupServerArgs(NodeContext& node);
72+
void SetupServerArgs(ArgsManager& argsman);
7373

7474
/** Returns licensing information (for -version) */
7575
std::string LicenseInfo();

src/init/bitcoin-node.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <interfaces/init.h>
77
#include <interfaces/ipc.h>
88
#include <node/context.h>
9+
#include <util/system.h>
910

1011
#include <memory>
1112

@@ -20,6 +21,7 @@ class BitcoinNodeInit : public interfaces::Init
2021
: m_node(node),
2122
m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))
2223
{
24+
m_node.args = &gArgs;
2325
m_node.init = this;
2426
}
2527
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }

src/init/bitcoind.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <interfaces/init.h>
66
#include <node/context.h>
7+
#include <util/system.h>
78

89
#include <memory>
910

@@ -14,6 +15,7 @@ class BitcoindInit : public interfaces::Init
1415
public:
1516
BitcoindInit(NodeContext& node) : m_node(node)
1617
{
18+
m_node.args = &gArgs;
1719
m_node.init = this;
1820
}
1921
NodeContext& m_node;

src/qt/bitcoin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ int GuiMain(int argc, char* argv[])
490490

491491
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
492492
// Command-line options take precedence:
493-
SetupServerArgs(node_context);
493+
SetupServerArgs(gArgs);
494494
SetupUIArgs(gArgs);
495495
std::string error;
496496
if (!gArgs.ParseParameters(argc, argv, error)) {

src/test/util/setup_common.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
7676
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
7777
m_args{}
7878
{
79+
m_node.args = &gArgs;
7980
const std::vector<const char*> arguments = Cat(
8081
{
8182
"dummy",
@@ -94,7 +95,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
9495
gArgs.ForceSetArg("-datadir", m_path_root.string());
9596
gArgs.ClearPathCache();
9697
{
97-
SetupServerArgs(m_node);
98+
SetupServerArgs(*m_node.args);
9899
std::string error;
99100
const bool success{m_node.args->ParseParameters(arguments.size(), arguments.data(), error)};
100101
assert(success);

0 commit comments

Comments
 (0)