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 
16 namespace init {
17 namespace {
18 const char* EXE_NAME = "bitcoin-gui";
19 
20 class BitcoinGuiInit : public interfaces::Init
21 {
22 public:
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 
42 namespace interfaces {
43 std::unique_ptr<Init> MakeGuiInit(int argc, char* argv[])
44 {
45  return std::make_unique<init::BitcoinGuiInit>(argc > 0 ? argv[0] : "");
46 }
47 } // namespace interfaces
interfaces
Definition: dummywallet.cpp:11
interfaces::MakeIpc
std::unique_ptr< Ipc > MakeIpc(const char *exe_name, const char *process_argv0, Init &init)
Return implementation of Ipc interface.
Definition: interfaces.cpp:74
NodeContext::args
ArgsManager * args
Definition: context.h:49
ipc
Definition: ipc.h:12
interfaces::MakeChain
std::unique_ptr< Chain > MakeChain(NodeContext &node)
Return implementation of Chain interface.
Definition: interfaces.cpp:734
interfaces::Init
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:26
chain.h
interfaces::MakeWalletClient
std::unique_ptr< WalletClient > MakeWalletClient(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet client.
Definition: dummywallet.cpp:67
context.h
interfaces::MakeGuiInit
std::unique_ptr< Init > MakeGuiInit(int argc, char *argv[])
Return implementation of Init interface for the gui process.
Definition: bitcoin-gui.cpp:43
Assert
#define Assert(val)
Identity function.
Definition: check.h:57
m_ipc
std::unique_ptr< interfaces::Ipc > m_ipc
Definition: bitcoin-gui.cpp:37
interfaces::Chain
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:92
NodeContext::init
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:41
echo.h
node.h
m_node
NodeContext m_node
Definition: bitcoin-gui.cpp:36
init.h
interfaces::MakeEcho
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: echo.cpp:17
gArgs
ArgsManager gArgs
Definition: system.cpp:85
ipc.h
system.h
init
Definition: bitcoin-gui.cpp:16
interfaces::MakeNode
std::unique_ptr< Node > MakeNode(NodeContext &context)
Return implementation of Node interface.
Definition: interfaces.cpp:733
wallet.h
NodeContext
NodeContext struct containing references to chain state and connection state.
Definition: context.h:39
interfaces::Ipc
Interface providing access to interprocess-communication (IPC) functionality.
Definition: ipc.h:44