CCrypter: move relevant implementation out of the header

This commit is contained in:
Jonas Schnelli
2017-09-07 13:25:43 -07:00
parent 3155fd23f2
commit 208fda69b3
2 changed files with 41 additions and 40 deletions

View File

@@ -153,6 +153,18 @@ bool CCryptoKeyStore::SetCrypted()
return true;
}
bool CCryptoKeyStore::IsLocked() const
{
if (!IsCrypted())
return false;
bool result;
{
LOCK(cs_KeyStore);
result = vMasterKey.empty();
}
return result;
}
bool CCryptoKeyStore::Lock()
{
if (!SetCrypted())
@@ -239,6 +251,18 @@ bool CCryptoKeyStore::AddCryptedKey(const CPubKey &vchPubKey, const std::vector<
return true;
}
bool CCryptoKeyStore::HaveKey(const CKeyID &address) const
{
{
LOCK(cs_KeyStore);
if (!IsCrypted()) {
return CBasicKeyStore::HaveKey(address);
}
return mapCryptedKeys.count(address) > 0;
}
return false;
}
bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
{
{
@@ -275,6 +299,19 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co
}
}
std::set<CKeyID> CCryptoKeyStore::GetKeys() const
{
LOCK(cs_KeyStore);
if (!IsCrypted()) {
return CBasicKeyStore::GetKeys();
}
std::set<CKeyID> set_address;
for (const auto& mi : mapCryptedKeys) {
set_address.insert(mi.first);
}
return set_address;
}
bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
{
{