Add GetNewDestination to CWallet to fetch new destinations

Instead of having the same multiple lines of code everywhere
that new destinations are fetched, introduce GetNewDestination as
a member function of CWallet which does the key fetching, label
setting, script generation, and destination generation.
This commit is contained in:
Andrew Chow
2019-06-18 15:19:13 -04:00
parent 0853d8d2fd
commit 172213be5b
9 changed files with 52 additions and 41 deletions

View File

@@ -140,9 +140,11 @@ public:
void abortRescan() override { m_wallet->AbortRescan(); }
bool backupWallet(const std::string& filename) override { return m_wallet->BackupWallet(filename); }
std::string getWalletName() override { return m_wallet->GetName(); }
bool getKeyFromPool(bool internal, CPubKey& pub_key) override
bool getNewDestination(const OutputType type, const std::string label, CTxDestination& dest) override
{
return m_wallet->GetKeyFromPool(pub_key, internal);
LOCK(m_wallet->cs_wallet);
std::string error;
return m_wallet->GetNewDestination(type, label, dest, error);
}
bool getPubKey(const CKeyID& address, CPubKey& pub_key) override { return m_wallet->GetPubKey(address, pub_key); }
bool getPrivKey(const CKeyID& address, CKey& key) override { return m_wallet->GetKey(address, key); }

View File

@@ -76,8 +76,8 @@ public:
//! Get wallet name.
virtual std::string getWalletName() = 0;
// Get key from pool.
virtual bool getKeyFromPool(bool internal, CPubKey& pub_key) = 0;
// Get a new address.
virtual bool getNewDestination(const OutputType type, const std::string label, CTxDestination& dest) = 0;
//! Get public key.
virtual bool getPubKey(const CKeyID& address, CPubKey& pub_key) = 0;