Cache note decryptors in encrypted keystore
This commit is contained in:
@@ -318,13 +318,15 @@ bool CCryptoKeyStore::AddSpendingKey(const libzcash::SpendingKey &sk)
|
||||
if (!EncryptSecret(vMasterKey, vchSecret, address.GetHash(), vchCryptedSecret))
|
||||
return false;
|
||||
|
||||
if (!AddCryptedSpendingKey(address, vchCryptedSecret))
|
||||
if (!AddCryptedSpendingKey(address, sk.viewing_key(), vchCryptedSecret))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::PaymentAddress &address, const std::vector<unsigned char> &vchCryptedSecret)
|
||||
bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::PaymentAddress &address,
|
||||
const libzcash::ViewingKey &vk,
|
||||
const std::vector<unsigned char> &vchCryptedSecret)
|
||||
{
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
@@ -332,6 +334,7 @@ bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::PaymentAddress &addr
|
||||
return false;
|
||||
|
||||
mapCryptedSpendingKeys[address] = vchCryptedSecret;
|
||||
mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(vk)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -383,7 +386,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
||||
std::vector<unsigned char> vchCryptedSecret;
|
||||
if (!EncryptSecret(vMasterKeyIn, vchSecret, address.GetHash(), vchCryptedSecret))
|
||||
return false;
|
||||
if (!AddCryptedSpendingKey(address, vchCryptedSecret))
|
||||
if (!AddCryptedSpendingKey(address, sk.viewing_key(), vchCryptedSecret))
|
||||
return false;
|
||||
}
|
||||
mapSpendingKeys.clear();
|
||||
|
||||
Reference in New Issue
Block a user