query backing device
This commit is contained in:
@@ -639,6 +639,11 @@ bool WalletImpl::recoverFromDevice(const std::string &path, const std::string &p
|
||||
return true;
|
||||
}
|
||||
|
||||
Wallet::Device WalletImpl::getDeviceType() const
|
||||
{
|
||||
return static_cast<Wallet::Device>(m_wallet->get_device_type());
|
||||
}
|
||||
|
||||
bool WalletImpl::open(const std::string &path, const std::string &password)
|
||||
{
|
||||
clearStatus();
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
bool recoverFromDevice(const std::string &path,
|
||||
const std::string &password,
|
||||
const std::string &device_name);
|
||||
Device getDeviceType() const;
|
||||
bool close(bool store = true);
|
||||
std::string seed() const override;
|
||||
std::string getSeedLanguage() const override;
|
||||
|
||||
@@ -373,6 +373,10 @@ struct WalletListener
|
||||
*/
|
||||
struct Wallet
|
||||
{
|
||||
enum Device {
|
||||
Device_Software = 0,
|
||||
Device_Ledger = 1
|
||||
};
|
||||
|
||||
enum Status {
|
||||
Status_Ok,
|
||||
@@ -911,6 +915,12 @@ struct Wallet
|
||||
virtual bool unlockKeysFile() = 0;
|
||||
//! returns true if the keys file is locked
|
||||
virtual bool isKeysFileLocked() = 0;
|
||||
|
||||
/*!
|
||||
* \brief Queries backing device for wallet keys
|
||||
* \return Device they are on
|
||||
*/
|
||||
virtual Device getDeviceType() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1096,6 +1106,18 @@ struct WalletManager
|
||||
*/
|
||||
virtual bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief determine the key storage for the specified wallet file
|
||||
* \param device_type (OUT) wallet backend as enumerated in Wallet::Device
|
||||
* \param keys_file_name Keys file to verify password for
|
||||
* \param password Password to verify
|
||||
* \return true if password correct, else false
|
||||
*
|
||||
* for verification only - determines key storage hardware
|
||||
*
|
||||
*/
|
||||
virtual bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief findWallets - searches for the wallet files by given path name recursively
|
||||
* \param path - starting point to search
|
||||
|
||||
@@ -167,6 +167,14 @@ bool WalletManagerImpl::verifyWalletPassword(const std::string &keys_file_name,
|
||||
return tools::wallet2::verify_password(keys_file_name, password, no_spend_key, hw::get_device("default"), kdf_rounds);
|
||||
}
|
||||
|
||||
bool WalletManagerImpl::queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds) const
|
||||
{
|
||||
hw::device::device_type type;
|
||||
bool r = tools::wallet2::query_device(type, keys_file_name, password, kdf_rounds);
|
||||
device_type = static_cast<Wallet::Device>(type);
|
||||
return r;
|
||||
}
|
||||
|
||||
std::vector<std::string> WalletManagerImpl::findWallets(const std::string &path)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
virtual bool closeWallet(Wallet *wallet, bool store = true) override;
|
||||
bool walletExists(const std::string &path) override;
|
||||
bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const override;
|
||||
bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const;
|
||||
std::vector<std::string> findWallets(const std::string &path) override;
|
||||
std::string errorString() const override;
|
||||
void setDaemonAddress(const std::string &address) override;
|
||||
|
||||
Reference in New Issue
Block a user