MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / LoadCryptedKey

Function LoadCryptedKey

src/wallet/walletdb.cpp:355–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355bool LoadCryptedKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr)
356{
357 LOCK(pwallet->cs_wallet);
358 try {
359 CPubKey vchPubKey;
360 ssKey >> vchPubKey;
361 if (!vchPubKey.IsValid())
362 {
363 strErr = "Error reading wallet database: CPubKey corrupt";
364 return false;
365 }
366 std::vector<unsigned char> vchPrivKey;
367 ssValue >> vchPrivKey;
368
369 // Get the checksum and check it
370 bool checksum_valid = false;
371 if (!ssValue.empty()) {
372 uint256 checksum;
373 ssValue >> checksum;
374 if (!(checksum_valid = Hash(vchPrivKey) == checksum)) {
375 strErr = "Error reading wallet database: Encrypted key corrupt";
376 return false;
377 }
378 }
379
380 if (!pwallet->GetOrCreateLegacyDataSPKM()->LoadCryptedKey(vchPubKey, vchPrivKey, checksum_valid))
381 {
382 strErr = "Error reading wallet database: LegacyDataSPKM::LoadCryptedKey failed";
383 return false;
384 }
385 } catch (const std::exception& e) {
386 if (strErr.empty()) {
387 strErr = e.what();
388 }
389 return false;
390 }
391 return true;
392}
393
394bool LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr)
395{

Callers 1

walletdb.cppFile · 0.85

Calls 6

LoadCryptedKeyMethod · 0.80
HashFunction · 0.50
IsValidMethod · 0.45
emptyMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected