Rename EncryptKeys to Encrypt and pass in the encrypted batch to use

This commit is contained in:
Andrew Chow
2019-12-05 18:23:57 -05:00
parent 35f962fcf0
commit 77a777118e
4 changed files with 17 additions and 13 deletions

View File

@@ -238,11 +238,15 @@ bool LegacyScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key
return true;
}
bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch)
{
AssertLockHeld(cs_wallet);
LOCK(cs_KeyStore);
if (!mapCryptedKeys.empty() || IsCrypted())
encrypted_batch = batch;
if (!mapCryptedKeys.empty() || IsCrypted()) {
encrypted_batch = nullptr;
return false;
}
fUseCrypto = true;
KeyMap keys_to_encrypt;
@@ -253,11 +257,16 @@ bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
CPubKey vchPubKey = key.GetPubKey();
CKeyingMaterial vchSecret(key.begin(), key.end());
std::vector<unsigned char> vchCryptedSecret;
if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret))
if (!EncryptSecret(master_key, vchSecret, vchPubKey.GetHash(), vchCryptedSecret)) {
encrypted_batch = nullptr;
return false;
if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
}
if (!AddCryptedKey(vchPubKey, vchCryptedSecret)) {
encrypted_batch = nullptr;
return false;
}
}
encrypted_batch = nullptr;
return true;
}