diff --git a/src/keystore.h b/src/keystore.h --- a/src/keystore.h +++ b/src/keystore.h @@ -88,4 +88,9 @@ */ CKeyID GetKeyForDestination(const CKeyStore &store, const CTxDestination &dest); +/** + * Checks if a CKey is in the given CKeyStore compressed or otherwise + */ +bool HaveKey(const CKeyStore &store, const CKey &key); + #endif // BITCOIN_KEYSTORE_H diff --git a/src/keystore.cpp b/src/keystore.cpp --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -169,3 +169,10 @@ } return CKeyID(); } + +bool HaveKey(const CKeyStore &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()); +}