aboutsummaryrefslogtreecommitdiff
path: root/db.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2010-12-16 11:36:47 -0500
committerGavin Andresen <gavinandresen@gmail.com>2010-12-16 11:36:47 -0500
commit55c43da5d8606f7abd22ee7af290cf10bb865f6a (patch)
treea22f32914f658d3dd713995ebc05bb45cee1bbd7 /db.cpp
parentbc530fe89fa2be0bbb991c4f65b187fc1dc00792 (diff)
parent809ee795927f0b9110a5b6e83845f42e3394451d (diff)
downloadbitcoin-55c43da5d8606f7abd22ee7af290cf10bb865f6a.tar.xz
Merge remote branch 'refs/remotes/svn/trunk' into svn
Diffstat (limited to 'db.cpp')
-rw-r--r--db.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/db.cpp b/db.cpp
index 8f02fffafa..38b1d6e579 100644
--- a/db.cpp
+++ b/db.cpp
@@ -592,9 +592,9 @@ bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account)
return Write(make_pair(string("acc"), strAccount), account);
}
-bool CWalletDB::WriteAccountingEntry(const string& strAccount, const CAccountingEntry& acentry)
+bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)
{
- return Write(make_tuple(string("acentry"), strAccount, ++nAccountingEntryNumber), acentry);
+ return Write(make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry);
}
int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
@@ -613,6 +613,8 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
{
int64 nCreditDebit = 0;
+ bool fAllAccounts = (strAccount == "*");
+
Dbc* pcursor = GetCursor();
if (!pcursor)
throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor");
@@ -622,7 +624,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
// Read next record
CDataStream ssKey;
if (fFlags == DB_SET_RANGE)
- ssKey << make_tuple(string("acentry"), strAccount, uint64(0));
+ ssKey << make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
CDataStream ssValue;
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
@@ -639,12 +641,11 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
ssKey >> strType;
if (strType != "acentry")
break;
- string strAccountName;
- ssKey >> strAccountName;
- if (strAccountName != strAccount)
+ CAccountingEntry acentry;
+ ssKey >> acentry.strAccount;
+ if (!fAllAccounts && acentry.strAccount != strAccount)
break;
- CAccountingEntry acentry;
ssValue >> acentry;
entries.push_back(acentry);
}
@@ -652,6 +653,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
pcursor->close();
}
+
bool CWalletDB::LoadWallet()
{
vchDefaultKey.clear();