Bitcoin Core  31.0.0
P2P Digital Currency
bitcoin-qt.cpp
Go to the documentation of this file.
1 // Copyright (c) 2021-present 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 <init.h>
6 #include <interfaces/chain.h>
7 #include <interfaces/echo.h>
8 #include <interfaces/init.h>
9 #include <interfaces/mining.h>
10 #include <interfaces/node.h>
11 #include <interfaces/wallet.h>
12 #include <node/context.h>
13 #include <util/check.h>
14 
15 #include <memory>
16 
17 namespace init {
18 namespace {
19 const char* EXE_NAME = "bitcoin-qt";
20 
21 class BitcoinQtInit : public interfaces::Init
22 {
23 public:
24  BitcoinQtInit()
25  {
27  m_node.init = this;
28  }
29  std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
30  std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
31  std::unique_ptr<interfaces::Mining> makeMining() override { return interfaces::MakeMining(m_node); }
32  std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
33  {
34  return MakeWalletLoader(chain, *Assert(m_node.args));
35  }
36  std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
37  const char* exeName() override { return EXE_NAME; }
39 };
40 } // namespace
41 } // namespace init
42 
43 namespace interfaces {
44 std::unique_ptr<Init> MakeGuiInit(int argc, char* argv[])
45 {
46  return std::make_unique<init::BitcoinQtInit>();
47 }
48 } // namespace interfaces
std::unique_ptr< Echo > MakeEcho()
Return implementation of Echo interface.
Definition: interfaces.cpp:52
std::unique_ptr< Node > MakeNode(node::NodeContext &context)
Return implementation of Node interface.
NodeContext struct containing references to chain state and connection state.
Definition: context.h:56
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
Definition: dummywallet.cpp:59
std::unique_ptr< Mining > MakeMining(node::NodeContext &node, bool wait_loaded=true)
Return implementation of Mining interface.
ArgsManager * args
Definition: context.h:74
node::NodeContext m_node
Definition: bitcoin-qt.cpp:38
interfaces::Init * init
Init interface for initializing current process and connecting to other processes.
Definition: context.h:61
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:117
Initial interface created when a process is first started, and used to give and get access to other i...
Definition: init.h:30
std::unique_ptr< Init > MakeGuiInit(int argc, char *argv[])
Return implementation of Init interface for the gui process.
Definition: bitcoin-gui.cpp:50
void InitContext(NodeContext &node)
Initialize node context shutdown and args variables.
Definition: init.cpp:213
#define Assert(val)
Identity function.
Definition: check.h:113