MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / ReadKeyValue

Function ReadKeyValue

src/wallet/walletdb.cpp:353–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351};
352
353bool
354ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
355 CWalletScanState &wss, string& strType, string& strErr)
356{
357 try {
358 // Unserialize
359 // Taking advantage of the fact that pair serialization
360 // is just the two items serialized one after the other
361 ssKey >> strType;
362 if (strType == "name")
363 {
364 string strAddress;
365 ssKey >> strAddress;
366 ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()].name;
367 }
368 else if (strType == "purpose")
369 {
370 string strAddress;
371 ssKey >> strAddress;
372 ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()].purpose;
373 }
374 else if (strType == "tx")
375 {
376 uint256 hash;
377 ssKey >> hash;
378 CWalletTx wtx;
379 ssValue >> wtx;
380 CValidationState state;
381 if (!(CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid()))
382 return false;
383
384 // Undo serialize changes in 31600
385 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
386 {
387 if (!ssValue.empty())
388 {
389 char fTmp;
390 char fUnused;
391 ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
392 strErr = strprintf("LoadWallet() upgrading tx ver=%d %d '%s' %s",
393 wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount, hash.ToString());
394 wtx.fTimeReceivedIsTxTime = fTmp;
395 }
396 else
397 {
398 strErr = strprintf("LoadWallet() repairing tx ver=%d %s", wtx.fTimeReceivedIsTxTime, hash.ToString());
399 wtx.fTimeReceivedIsTxTime = 0;
400 }
401 wss.vWalletUpgrade.push_back(hash);
402 }
403
404 if (wtx.nOrderPos == -1)
405 wss.fAnyUnordered = true;
406
407 pwallet->AddToWallet(wtx, true, NULL);
408 }
409 else if (strType == "acentry")
410 {

Callers 2

LoadWalletMethod · 0.85
BOOST_FOREACHFunction · 0.85

Calls 15

CBitcoinAddressClass · 0.85
CheckTransactionFunction · 0.85
CKeyMetadataClass · 0.85
AddToWalletMethod · 0.80
LoadWatchOnlyMethod · 0.80
reserveMethod · 0.80
LoadMethod · 0.80
LoadKeyMethod · 0.80
countMethod · 0.80
LoadCryptedKeyMethod · 0.80
LoadKeyMetadataMethod · 0.80
GetIDMethod · 0.80

Tested by

no test coverage detected