Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
bool WalletBatch::WriteAccountingEntry(const uint64_t nAccEntryNum, | bool WalletBatch::WriteAccountingEntry(const uint64_t nAccEntryNum, | ||||
const CAccountingEntry &acentry) { | const CAccountingEntry &acentry) { | ||||
return WriteIC( | return WriteIC( | ||||
std::make_pair(std::string("acentry"), | std::make_pair(std::string("acentry"), | ||||
std::make_pair(acentry.strAccount, nAccEntryNum)), | std::make_pair(acentry.strAccount, nAccEntryNum)), | ||||
acentry); | acentry); | ||||
} | } | ||||
Amount WalletBatch::GetAccountCreditDebit(const std::string &strAccount) { | |||||
std::list<CAccountingEntry> entries; | |||||
ListAccountCreditDebit(strAccount, entries); | |||||
Amount nCreditDebit = Amount::zero(); | |||||
for (const CAccountingEntry &entry : entries) { | |||||
nCreditDebit += entry.nCreditDebit; | |||||
} | |||||
return nCreditDebit; | |||||
} | |||||
void WalletBatch::ListAccountCreditDebit(const std::string &strAccount, | void WalletBatch::ListAccountCreditDebit(const std::string &strAccount, | ||||
std::list<CAccountingEntry> &entries) { | std::list<CAccountingEntry> &entries) { | ||||
bool fAllAccounts = (strAccount == "*"); | bool fAllAccounts = (strAccount == "*"); | ||||
Dbc *pcursor = m_batch.GetCursor(); | Dbc *pcursor = m_batch.GetCursor(); | ||||
if (!pcursor) { | if (!pcursor) { | ||||
throw std::runtime_error(std::string(__func__) + | throw std::runtime_error(std::string(__func__) + | ||||
": cannot create DB cursor"); | ": cannot create DB cursor"); | ||||
▲ Show 20 Lines • Show All 690 Lines • Show Last 20 Lines |