Move HaveKey static function from keystore to rpcwallet where it is used

This commit is contained in:
Andrew Chow 2019-06-06 16:49:52 +02:00
parent c7797ec655
commit a913e3f2fb
3 changed files with 8 additions and 10 deletions

View file

@ -196,10 +196,3 @@ CKeyID GetKeyForDestination(const CBasicKeyStore& store, const CTxDestination& d
}
return CKeyID();
}
bool HaveKey(const CBasicKeyStore& store, const CKey& key)
{
CKey key2;
key2.Set(key.begin(), key.end(), !key.IsCompressed());
return store.HaveKey(key.GetPubKey().GetID()) || store.HaveKey(key2.GetPubKey().GetID());
}

View file

@ -54,7 +54,4 @@ public:
/** Return the CKeyID of the key involved in a script (if there is a unique one). */
CKeyID GetKeyForDestination(const CBasicKeyStore& store, const CTxDestination& dest);
/** Checks if a CKey is in the given CBasicKeyStore compressed or otherwise*/
bool HaveKey(const CBasicKeyStore& store, const CKey& key);
#endif // BITCOIN_KEYSTORE_H

View file

@ -52,6 +52,14 @@ static inline bool GetAvoidReuseFlag(CWallet * const pwallet, const UniValue& pa
return avoid_reuse;
}
/** Checks if a CKey is in the given CWallet compressed or otherwise*/
bool HaveKey(const CWallet& wallet, const CKey& key)
{
CKey key2;
key2.Set(key.begin(), key.end(), !key.IsCompressed());
return wallet.HaveKey(key.GetPubKey().GetID()) || wallet.HaveKey(key2.GetPubKey().GetID());
}
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name)
{
if (request.URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {