Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2021-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <interfaces/init.h> // IWYU pragma: associated7#include <init.h>8#include <interfaces/chain.h>9#include <interfaces/echo.h>10#include <interfaces/ipc.h>11#include <interfaces/mining.h>12#include <interfaces/node.h>13#include <interfaces/rpc.h>14#include <interfaces/wallet.h>15#include <node/context.h>16#include <util/check.h>18#include <memory>20namespace init {21namespace {22const char* EXE_NAME = "bitcoin-node";24class BitcoinNodeInit : public interfaces::Init25{26public:27BitcoinNodeInit(node::NodeContext& node, const char* arg0)28: m_node(node),29m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))30{31InitContext(m_node);32m_node.init = this;33}34std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }35std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }36std::unique_ptr<interfaces::Mining> makeMining() override { return interfaces::MakeMining(m_node); }37std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override38{39return MakeWalletLoader(chain, *Assert(m_node.args));40}41std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }42std::unique_ptr<interfaces::Rpc> makeRpc() override { return interfaces::MakeRpc(m_node); }43interfaces::Ipc* ipc() override { return m_ipc.get(); }44bool canListenIpc() override { return true; }45const char* exeName() override { return EXE_NAME; }46node::NodeContext& m_node;47std::unique_ptr<interfaces::Ipc> m_ipc;48};49} // namespace50} // namespace init52namespace interfaces {53std::unique_ptr<Init> MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status)54{55auto init = std::make_unique<init::BitcoinNodeInit>(node, argc > 0 ? argv[0] : "");56// Check if bitcoin-node is being invoked as an IPC server. If so, then57// bypass normal execution and just respond to requests over the IPC58// channel and return null.59if (init->m_ipc->startSpawnedProcess(argc, argv, exit_status)) {60return nullptr;61}62return init;63}64} // namespace interfaces