MCPcopy Create free account
hub / github.com/ElementsProject/elements / Encrypt

Method Encrypt

src/wallet/scriptpubkeyman.cpp:276–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch)
277{
278 LOCK(cs_KeyStore);
279 encrypted_batch = batch;
280 if (!mapCryptedKeys.empty()) {
281 encrypted_batch = nullptr;
282 return false;
283 }
284
285 KeyMap keys_to_encrypt;
286 keys_to_encrypt.swap(mapKeys); // Clear mapKeys so AddCryptedKeyInner will succeed.
287 for (const KeyMap::value_type& mKey : keys_to_encrypt)
288 {
289 const CKey &key = mKey.second;
290 CPubKey vchPubKey = key.GetPubKey();
291 CKeyingMaterial vchSecret(key.begin(), key.end());
292 std::vector<unsigned char> vchCryptedSecret;
293 if (!EncryptSecret(master_key, vchSecret, vchPubKey.GetHash(), vchCryptedSecret)) {
294 encrypted_batch = nullptr;
295 return false;
296 }
297 if (!AddCryptedKey(vchPubKey, vchCryptedSecret)) {
298 encrypted_batch = nullptr;
299 return false;
300 }
301 }
302 encrypted_batch = nullptr;
303 return true;
304}
305
306bool LegacyScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool, bilingual_str& error)
307{

Callers

nothing calls this directly

Calls 10

EncryptSecretFunction · 0.85
emptyMethod · 0.45
swapMethod · 0.45
GetPubKeyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetHashMethod · 0.45
GetIDMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected