| 452 | }; |
| 453 | |
| 454 | bool 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 | } |
no test coverage detected