What's the deal with the bitcoin-wallet code?

2 replies 37 views
Posts: 3 · Reputation: 122
#1Aug 4, 2024, 12:32 PM
Check out the file src/bitcoin-wallet.cpp in the latest branch, specifically line 103: std::unique_ptr<interfaces::Init> init = interfaces::MakeWalletInit(argc, argv, exit_status); if (!init) { return exit_status; } This looks like it’s setting up the wallet, but I can't find much on interfaces::MakeWalletInit(argc, argv, exit_status) apart from what’s in src/init/bitcoin-wallet.cpp: namespace interfaces { std::unique_ptr<Init> MakeWalletInit(int argc, char* argv[], int& exit_status) { return std::make_unique<Init>(); } } // namespace interfaces But just returning a base Init object doesn’t seem very useful, right? I mean, the class itself is pretty bare: class Init { public: virtual ~Init() = default; virtual std::unique_ptr<Node> makeNode() { return nullptr; } virtual std::unique_ptr<Chain> makeChain() { return nullptr; } virtual std::unique_ptr<Mining> makeMining() { return nullptr; } virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain) { return nullptr; } virtual std::unique_ptr<Echo> makeEcho() { return nullptr; } virtual Ipc* ipc() { return nullptr; } virtual bool canListenIpc() { return false; } }; So what's the point of lines 103 to 106 in src/bitcoin-wallet.cpp? I’m confused.
6 Reply Quote Share
byte_orbitFull Member
Posts: 186 · Reputation: 738
#2Aug 4, 2024, 03:28 PM
This is related with the process separation project https://github.com/bitcoin/bitcoin/pull/23006 and https://github.com/orgs/bitcoin/projects/8/views/1. I think that this part is still not used, but I could be wrong. Someone more up to speed with the progress of the project could probably tell you more. If you are not familiar with the project, you can read more about it at the following links: https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Process-Separation https://github.com/ryanofsky/bitcoin/blob/ipc-export/doc/multiprocess.md#next-steps
6 Reply Quote Share
sage_moonSenior Member
Posts: 273 · Reputation: 1371
#3Aug 4, 2024, 09:17 PM
If my memory serves me correctly, I think MakeWalletInit is a dynamic function that depends on how BC is compiled, whether when it is compiled without a wallet enabled or with a wallet enabled, being a dynamic function, which does not strictly call specific functions but rather works as an interface to call whatever is required from the wallet. That is, its use depends on the type of object created. If I had to guess why this is done, I would say to ensure the scalability of Bitcoin development and compatibility with future implementations.
2 Reply Quote Share

Related topics