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

Method FindWalletTx

src/walletdb.cpp:860–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

858}
859
860DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash, vector<CWalletTx>& vWtx)
861{
862 pwallet->vchDefaultKey = CPubKey();
863 bool fNoncriticalErrors = false;
864 DBErrors result = DB_LOAD_OK;
865
866 try {
867 LOCK(pwallet->cs_wallet);
868 int nMinVersion = 0;
869 if (Read((string) "minversion", nMinVersion)) {
870 if (nMinVersion > CLIENT_VERSION)
871 return DB_TOO_NEW;
872 pwallet->LoadMinVersion(nMinVersion);
873 }
874
875 // Get cursor
876 Dbc* pcursor = GetCursor();
877 if (!pcursor) {
878 LogPrintf("Error getting wallet database cursor\n");
879 return DB_CORRUPT;
880 }
881
882 while (true) {
883 // Read next record
884 CDataStream ssKey(SER_DISK, CLIENT_VERSION);
885 CDataStream ssValue(SER_DISK, CLIENT_VERSION);
886 int ret = ReadAtCursor(pcursor, ssKey, ssValue);
887 if (ret == DB_NOTFOUND)
888 break;
889 else if (ret != 0) {
890 LogPrintf("Error reading next record from wallet database\n");
891 return DB_CORRUPT;
892 }
893
894 string strType;
895 ssKey >> strType;
896 if (strType == "tx") {
897 uint256 hash;
898 ssKey >> hash;
899
900 CWalletTx wtx;
901 ssValue >> wtx;
902
903 vTxHash.push_back(hash);
904 vWtx.push_back(wtx);
905 }
906 }
907 pcursor->close();
908 } catch (boost::thread_interrupted) {
909 throw;
910 } catch (...) {
911 result = DB_CORRUPT;
912 }
913
914 if (fNoncriticalErrors && result == DB_LOAD_OK)
915 result = DB_NONCRITICAL_ERROR;
916
917 return result;

Callers

nothing calls this directly

Calls 5

ReadClass · 0.85
LoadMinVersionMethod · 0.80
CPubKeyClass · 0.70
push_backMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected