From a913e3f2fbeb1352fc66f334d4f5f7332ea89ad7 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 6 Jun 2019 16:49:52 +0200 Subject: [PATCH] Move HaveKey static function from keystore to rpcwallet where it is used --- src/keystore.cpp | 7 ------- src/keystore.h | 3 --- src/wallet/rpcwallet.cpp | 8 ++++++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/keystore.cpp b/src/keystore.cpp index 8c149a92500..0319c469fcd 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -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()); -} diff --git a/src/keystore.h b/src/keystore.h index b8f5a430eb6..3e46acda1d0 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -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 diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index eae5f876ea7..bc866657825 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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) {