| 351 | }; |
| 352 | |
| 353 | bool |
| 354 | ReadKeyValue(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 | { |
no test coverage detected