interfaces: Add loadWallet to Node

This commit is contained in:
João Barbosa 2019-01-12 11:36:38 +00:00
parent 17abc0fd52
commit ab288b4e59
2 changed files with 10 additions and 0 deletions

View file

@ -42,6 +42,7 @@ class CWallet;
fs::path GetWalletDir();
std::vector<fs::path> ListWalletDir();
std::vector<std::shared_ptr<CWallet>> GetWallets();
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, std::string& error, std::string& warning);
namespace interfaces {
@ -252,6 +253,10 @@ public:
}
return wallets;
}
std::unique_ptr<Wallet> loadWallet(const std::string& name, std::string& error, std::string& warning) override
{
return MakeWallet(LoadWallet(*m_interfaces.chain, name, error, warning));
}
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override
{
return MakeHandler(::uiInterface.InitMessage_connect(fn));

View file

@ -192,6 +192,11 @@ public:
//! Return interfaces for accessing wallets (if any).
virtual std::vector<std::unique_ptr<Wallet>> getWallets() = 0;
//! Attempts to load a wallet from file or directory.
//! The loaded wallet is also notified to handlers previously registered
//! with handleLoadWallet.
virtual std::unique_ptr<Wallet> loadWallet(const std::string& name, std::string& error, std::string& warning) = 0;
//! Register handler for init messages.
using InitMessageFn = std::function<void(const std::string& message)>;
virtual std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) = 0;