MCPcopy Create free account
hub / github.com/LUX-Core/lux / ReadKeyValue

Function ReadKeyValue

src/walletdb.cpp:454–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452};
453
454bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, CWalletScanState& wss, string& strType, string& strErr)
455{
456 try {
457 // Unserialize
458 // Taking advantage of the fact that pair serialization
459 // is just the two items serialized one after the other
460 ssKey >> strType;
461 if (strType == "name") {
462 string strAddress;
463 ssKey >> strAddress;
464 ssValue >> pwallet->mapAddressBook[DecodeDestination(strAddress)].name;
465 } else if (strType == "purpose") {
466 string strAddress;
467 ssKey >> strAddress;
468 ssValue >> pwallet->mapAddressBook[DecodeDestination(strAddress)].purpose;
469 } else if (strType == "tx") {
470 uint256 hash;
471 ssKey >> hash;
472 CWalletTx wtx;
473 ssValue >> wtx;
474 CValidationState state;
475 if (!(CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid()))
476 return false;
477
478 // Undo serialize changes in 31600
479 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) {
480 if (!ssValue.empty()) {
481 char fTmp;
482 char fUnused;
483 ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
484 strErr = strprintf("LoadWallet() upgrading tx ver=%d %d '%s' %s",
485 wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount, hash.ToString());
486 wtx.fTimeReceivedIsTxTime = fTmp;
487 } else {
488 strErr = strprintf("LoadWallet() repairing tx ver=%d %s", wtx.fTimeReceivedIsTxTime, hash.ToString());
489 wtx.fTimeReceivedIsTxTime = 0;
490 }
491 wss.vWalletUpgrade.push_back(hash);
492 }
493
494 if (wtx.nOrderPos == -1)
495 wss.fAnyUnordered = true;
496
497 pwallet->AddToWallet(wtx, true);
498 } else if (strType == "acentry") {
499 string strAccount;
500 ssKey >> strAccount;
501 uint64_t nNumber;
502 ssKey >> nNumber;
503 if (nNumber > nAccountingEntryNumber)
504 nAccountingEntryNumber = nNumber;
505
506 if (!wss.fAnyUnordered) {
507 CAccountingEntry acentry;
508 ssValue >> acentry;
509 if (acentry.nOrderPos == -1)
510 wss.fAnyUnordered = true;
511 }

Callers 2

LoadWalletMethod · 0.85
RecoverMethod · 0.85

Calls 15

DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
LoadWatchOnlyMethod · 0.80
LoadKeyMethod · 0.80
LoadCryptedKeyMethod · 0.80
LoadKeyMetadataMethod · 0.80
LoadKeyPoolMethod · 0.80
LoadCScriptMethod · 0.80
SetSplitThresholdMethod · 0.80
LoadDestDataMethod · 0.80
LoadTokenMethod · 0.80
LoadTokenTxMethod · 0.80

Tested by

no test coverage detected