refactor: Move wallet methods out of chain.h and node.h

Add WalletClient interface so node interface is cleaner and don't need
wallet-specific methods.

The new NodeContext::wallet_client pointer will also be needed to eliminate
global wallet variables like ::vpwallets, because createWallet(), loadWallet(),
getWallets(), etc methods called by the GUI need a way to get a reference to
the list of open wallets if it is no longer a global variable.

Also tweaks splash screen registration for load wallet events to be delayed
until after wallet client is created.
This commit is contained in:
Russell Yanofsky
2020-05-28 09:48:30 -04:00
parent b266b3e0bf
commit e4f4350471
20 changed files with 111 additions and 139 deletions

View File

@@ -4,11 +4,8 @@
#include <util/system.h>
#include <walletinitinterface.h>
#include <support/allocators/secure.h>
class CWallet;
enum class WalletCreationStatus;
struct bilingual_str;
namespace interfaces {
class Chain;
@@ -59,37 +56,6 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
fs::path GetWalletDir()
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
std::vector<fs::path> ListWalletDir()
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
std::vector<std::shared_ptr<CWallet>> GetWallets()
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, bilingual_str& error, std::vector<bilingual_str>& warnings)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
WalletCreationStatus CreateWallet(interfaces::Chain& chain, const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, bilingual_str& error, std::vector<bilingual_str>& warnings, std::shared_ptr<CWallet>& result)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
std::unique_ptr<interfaces::Handler> HandleLoadWallet(LoadWalletFn load_wallet)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
namespace interfaces {
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)