| 1037 | } |
| 1038 | |
| 1039 | DBErrors WalletBatch::FindWalletTx(std::vector<uint256>& vTxHash, std::list<CWalletTx>& vWtx) |
| 1040 | { |
| 1041 | DBErrors result = DBErrors::LOAD_OK; |
| 1042 | |
| 1043 | try { |
| 1044 | int nMinVersion = 0; |
| 1045 | if (m_batch->Read(DBKeys::MINVERSION, nMinVersion)) { |
| 1046 | if (nMinVersion > FEATURE_LATEST) |
| 1047 | return DBErrors::TOO_NEW; |
| 1048 | } |
| 1049 | |
| 1050 | // Get cursor |
| 1051 | if (!m_batch->StartCursor()) |
| 1052 | { |
| 1053 | LogPrintf("Error getting wallet database cursor\n"); |
| 1054 | return DBErrors::CORRUPT; |
| 1055 | } |
| 1056 | |
| 1057 | while (true) |
| 1058 | { |
| 1059 | // Read next record |
| 1060 | CDataStream ssKey(SER_DISK, CLIENT_VERSION); |
| 1061 | CDataStream ssValue(SER_DISK, CLIENT_VERSION); |
| 1062 | bool complete; |
| 1063 | bool ret = m_batch->ReadAtCursor(ssKey, ssValue, complete); |
| 1064 | if (complete) { |
| 1065 | break; |
| 1066 | } else if (!ret) { |
| 1067 | m_batch->CloseCursor(); |
| 1068 | LogPrintf("Error reading next record from wallet database\n"); |
| 1069 | return DBErrors::CORRUPT; |
| 1070 | } |
| 1071 | |
| 1072 | std::string strType; |
| 1073 | ssKey >> strType; |
| 1074 | if (strType == DBKeys::TX) { |
| 1075 | uint256 hash; |
| 1076 | ssKey >> hash; |
| 1077 | vTxHash.push_back(hash); |
| 1078 | vWtx.emplace_back(/*tx=*/nullptr, TxStateInactive{}); |
| 1079 | ssValue >> vWtx.back(); |
| 1080 | } |
| 1081 | } |
| 1082 | } catch (...) { |
| 1083 | result = DBErrors::CORRUPT; |
| 1084 | } |
| 1085 | m_batch->CloseCursor(); |
| 1086 | |
| 1087 | return result; |
| 1088 | } |
| 1089 | |
| 1090 | DBErrors WalletBatch::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uint256>& vTxHashOut) |
| 1091 | { |
nothing calls this directly
no test coverage detected