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

pull/12560/head
Andrew Chow 7 years ago
parent f82e1c9482
commit dd3c07acce

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

@ -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). */ /** Return the CKeyID of the key involved in a script (if there is a unique one). */
CKeyID GetKeyForDestination(const CKeyStore& store, const CTxDestination& dest); 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 #endif // BITCOIN_KEYSTORE_H

Loading…
Cancel
Save