Separate HaveKey function that checks whether a key is in a keystore

This commit is contained in:
Andrew Chow 2018-04-12 17:04:49 -04:00
parent f82e1c9482
commit dd3c07acce
2 changed files with 10 additions and 0 deletions

View file

@ -195,3 +195,10 @@ CKeyID GetKeyForDestination(const CKeyStore& store, const CTxDestination& dest)
}
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());
}

View file

@ -80,4 +80,7 @@ typedef std::map<CKeyID, std::pair<CPubKey, std::vector<unsigned char> > > Crypt
/** Return the CKeyID of the key involved in a script (if there is a unique one). */
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