Bitcoin Core 22.99.0
P2P Digital Currency
bitcoin-gui.cpp
Go to the documentation of this file.
1// Copyright (c) 2021 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <interfaces/chain.h>
6#include <interfaces/echo.h>
7#include <interfaces/init.h>
8#include <interfaces/ipc.h>
9#include <interfaces/node.h>
10#include <interfaces/wallet.h>
11#include <node/context.h>
12#include <util/system.h>
13
14#include <memory>
15
16namespace init {
17namespace {
18const char* EXE_NAME = "bitcoin-gui";
19
20class BitcoinGuiInit : public interfaces::Init
21{
22public:
23 BitcoinGuiInit(const char* arg0) : m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))
24 {
25 m_node.args = &gArgs;
26 m_node.init = this;
27 }
28 std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
29 std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
30 std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override
31 {
32 return MakeWalletClient(chain, *Assert(m_node.args));
33 }
34 std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
35 interfaces::Ipc* ipc() override { return m_ipc.get(); }
37 std::unique_ptr<interfaces::Ipc> m_ipc;
38};
39} // namespace
40} // namespace init
41
42namespace interfaces {
43std::unique_ptr<Init> MakeGuiInit(int argc, char* argv[])
44{
45 return std::make_unique<init::BitcoinGuiInit>(argc > 0 ? argv[0] : "");
46}
47} // namespace interfaces
std::unique_ptr< interfaces::Ipc > m_ipc
Definition: bitcoin-gui.cpp:37
NodeContext m_node
Definition: bitcoin-gui.cpp:36
#define Assert(val)
Identity function.
Definition: check.h:57
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:93
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:27
Interface providing access to interprocess-communication (IPC) functionality.
Definition: ipc.h:45
std::unique_ptr< Chain > MakeChain(NodeContext &node)
Return implementation of Chain interface.
Definition: interfaces.cpp:714
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: echo.cpp:17
std::unique_ptr< Init > MakeGuiInit(int argc, char *argv[])
Return implementation of Init interface for the gui process.
Definition: bitcoin-gui.cpp:43
std::unique_ptr< Ipc > MakeIpc(const char *exe_name, const char *process_argv0, Init &init)
Return implementation of Ipc interface.
Definition: interfaces.cpp:74
std::unique_ptr< WalletClient > MakeWalletClient(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet client.
Definition: dummywallet.cpp:67
std::unique_ptr< Node > MakeNode(NodeContext &context)
Return implementation of Node interface.
Definition: interfaces.cpp:713
Definition: ipc.h:12
NodeContext struct containing references to chain state and connection state.
Definition: context.h:39
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:41
ArgsManager * args
Definition: context.h:49
ArgsManager gArgs
Definition: system.cpp:85