diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 61f8848..5fe9aea 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -168,17 +168,19 @@ void CWalletDB::ListAccountCreditDebit(const std::string& strAccount, std::list< break; } - // Unserialize. We mirror the Berkeley read: stop at the first non-acentry - // record (which is the next record type in key order — Berkeley's - // DB_SET_RANGE/DB_NEXT loop also terminated when the prefix changed). + // Unserialize. Unlike the Berkeley cursor -- which iterated in sorted + // key order and was positioned at the ("acentry", strAccount) prefix + // via DB_SET_RANGE, so it could stop at the first non-matching record -- + // the SQLite cursor scans the whole keyspace in unspecified order. + // We must therefore skip non-matching records and keep scanning. std::string strType; ssKey >> strType; if (strType != "acentry") - break; + continue; CAccountingEntry acentry; ssKey >> acentry.strAccount; if (!fAllAccounts && acentry.strAccount != strAccount) - break; + continue; ssValue >> acentry; ssKey >> acentry.nEntryNo;