aboutsummaryrefslogtreecommitdiff
path: root/db.cpp
diff options
context:
space:
mode:
authorgavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-11-30 18:58:11 +0000
committergavinandresen <gavinandresen@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-11-30 18:58:11 +0000
commitbfd471f53e14c4218ae7a1544beb7f1de3e695b2 (patch)
treece973160466913efe4a091eb47da3e1f8b90f388 /db.cpp
parent84d7c981dc52cc738053f9ec48648ab6fbf9311b (diff)
downloadbitcoin-bfd471f53e14c4218ae7a1544beb7f1de3e695b2.tar.xz
JSON methods: listtransactions, gettransaction, move, sendfrom and getbalance <account>
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@193 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'db.cpp')
-rw-r--r--db.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/db.cpp b/db.cpp
index 2833a8be91..40998fb740 100644
--- a/db.cpp
+++ b/db.cpp
@@ -597,11 +597,23 @@ bool CWalletDB::WriteAccountingEntry(const string& strAccount, const CAccounting
int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
{
+ list<CAccountingEntry> entries;
+ ListAccountCreditDebit(strAccount, entries);
+
+ int64 nCreditDebit = 0;
+ foreach (const CAccountingEntry& entry, entries)
+ nCreditDebit += entry.nCreditDebit;
+
+ return nCreditDebit;
+}
+
+void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries)
+{
int64 nCreditDebit = 0;
Dbc* pcursor = GetCursor();
if (!pcursor)
- throw runtime_error("CWalletDB::GetAccountCreditDebit() : cannot create DB cursor");
+ throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor");
unsigned int fFlags = DB_SET_RANGE;
loop
{
@@ -617,7 +629,7 @@ int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
else if (ret != 0)
{
pcursor->close();
- throw runtime_error("CWalletDB::GetAccountCreditDebit() : error scanning DB");
+ throw runtime_error("CWalletDB::ListAccountCreditDebit() : error scanning DB");
}
// Unserialize
@@ -632,11 +644,10 @@ int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
CAccountingEntry acentry;
ssValue >> acentry;
- nCreditDebit += acentry.nCreditDebit;
+ entries.push_back(acentry);
}
pcursor->close();
- return nCreditDebit;
}
bool CWalletDB::LoadWallet()