What changed, and why it matters
This commit adds a small helper function that makes it easier for simple Bitcoin tools (like command-line utilities) to connect to other Bitcoin processes over IPC without needing to write boilerplate setup code. It does not change existing behavior or fix any bug; it is purely a code organization and convenience addition.
No security action needed. This is a benign refactoring/helper addition. Review as part of normal code review if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces MakeBasicInit() in src/init/basic.cpp and declares it in src/interfaces/init.h. It returns a minimal interfaces::Init implementation (BitcoinBasicInit) that only provides an Ipc object and leaves all other factory methods returning null. This is intended for standalone IPC clients that initiate connections but do not expose services themselves, such as bitcoin-mine and bitcoin-cli in referenced PRs. The implementation is straightforward: it wraps interfaces::MakeIpc() and stores the result in a unique_ptr member.
Changed components
src/init/basic.cppsrc/interfaces/init.hInspect captured patch +45 / −0
diff --git a/src/init/basic.cpp b/src/init/basic.cpp
new file mode 100644
index 00000000..12d468c0
--- /dev/null
+++ b/src/init/basic.cpp
@@ -0,0 +1,26 @@
+// Copyright (c) 2025 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <interfaces/init.h>
+#include <interfaces/ipc.h>
+
+namespace init {
+namespace {
+class BitcoinBasicInit : public interfaces::Init
+{
+public:
+ BitcoinBasicInit(const char* exe_name, const char* process_argv0) : m_ipc(interfaces::MakeIpc(exe_name, process_argv0, *this)) {}
+ interfaces::Ipc* ipc() override { return m_ipc.get(); }
+private:
+ std::unique_ptr<interfaces::Ipc> m_ipc;
+};
+} // namespace
+} // namespace init
+
+namespace interfaces {
+std::unique_ptr<Init> MakeBasicInit(const char* exe_name, const char* process_argv0)
+{
+ return std::make_unique<init::BitcoinBasicInit>(exe_name, process_argv0);
+}
+} // namespace interfaces
diff --git a/src/interfaces/init.h b/src/interfaces/init.h
index 463d43e7..f214b287 100644
--- a/src/interfaces/init.h
+++ b/src/interfaces/init.h
@@ -55,6 +55,25 @@ std::unique_ptr<Init> MakeWalletInit(int argc, char* argv[], int& exit_status);
//! Return implementation of Init interface for the gui process.
std::unique_ptr<Init> MakeGuiInit(int argc, char* argv[]);
+
+//! Return implementation of Init interface for a basic IPC client that doesn't
+//! provide any IPC services itself.
+//!
+//! When an IPC client connects to a socket or spawns a process, it gets a pointer
+//! to an Init object allowing it to create objects and threads on the remote
+//! side of the IPC connection. But the client also needs to provide a local Init
+//! object to allow the remote side of the connection to create objects and
+//! threads on this side. This function just returns a basic Init object
+//! allowing remote connections to only create local threads, not other objects
+//! (because its Init::make* methods return null.)
+//!
+//! @param exe_name Current executable name, which is just passed to the IPC
+//! system and used for logging.
+//!
+//! @param process_argv0 Optional string containing argv[0] value passed to
+//! main(). This is passed to the IPC system and used to locate binaries by
+//! relative path if subprocesses are spawned.
+std::unique_ptr<Init> MakeBasicInit(const char* exe_name, const char* process_argv0="");
} // namespace interfaces
#endif // BITCOIN_INTERFACES_INIT_H
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.