diff options
author | Andrew Chow <achow101-github@achow101.com> | 2019-12-05 18:23:57 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-12-06 15:05:48 -0500 |
commit | 77a777118eaf78f10a439810d1c08d510a539aa0 (patch) | |
tree | 3abffca64ce466ec095472740316248f7043e1e8 /src/wallet/scriptpubkeyman.cpp | |
parent | 35f962fcf0d5107ae6a3a9348e249a9b18ff7106 (diff) | |
download | bitcoin-77a777118eaf78f10a439810d1c08d510a539aa0.tar.xz |
Rename EncryptKeys to Encrypt and pass in the encrypted batch to use
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index acf3ed2e2b..4d8a7e2d38 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -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; } |