aboutsummaryrefslogtreecommitdiff
path: root/db.cpp
diff options
context:
space:
mode:
authorgavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-12-16 01:06:03 +0000
committergavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-12-16 01:06:03 +0000
commit809ee795927f0b9110a5b6e83845f42e3394451d (patch)
treea906fe04ac63e46d82793d893b8aa69960de6df7 /db.cpp
parent629e37dde1fa93f6ce31544d1ebb5ee5c19052cb (diff)
New RPC command: listaccounts. New RPC setting -rpctimeout. And listtransactions '*'
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@203 1a98c847-1fd6-4fd8-948a-caf3550aa51b
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();