Skip to content

Commit 02e2a81

Browse files
committed
Remove pwalletdb parameter from CWallet::AddAccountingEntry
1 parent d2e678d commit 02e2a81

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/wallet/test/accounting_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
4545
ae.nTime = 1333333333;
4646
ae.strOtherAccount = "b";
4747
ae.strComment = "";
48-
pwalletMain->AddAccountingEntry(ae, walletdb);
48+
pwalletMain->AddAccountingEntry(ae);
4949

5050
wtx.mapValue["comment"] = "z";
5151
pwalletMain->AddToWallet(wtx);
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
5555

5656
ae.nTime = 1333333336;
5757
ae.strOtherAccount = "c";
58-
pwalletMain->AddAccountingEntry(ae, walletdb);
58+
pwalletMain->AddAccountingEntry(ae);
5959

6060
GetResults(walletdb, results);
6161

@@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
7171
ae.nTime = 1333333330;
7272
ae.strOtherAccount = "d";
7373
ae.nOrderPos = pwalletMain->IncOrderPosNext();
74-
pwalletMain->AddAccountingEntry(ae, walletdb);
74+
pwalletMain->AddAccountingEntry(ae);
7575

7676
GetResults(walletdb, results);
7777

@@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
121121
ae.nTime = 1333333334;
122122
ae.strOtherAccount = "e";
123123
ae.nOrderPos = -1;
124-
pwalletMain->AddAccountingEntry(ae, walletdb);
124+
pwalletMain->AddAccountingEntry(ae);
125125

126126
GetResults(walletdb, results);
127127

src/wallet/wallet.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
683683
debit.nTime = nNow;
684684
debit.strOtherAccount = strTo;
685685
debit.strComment = strComment;
686-
AddAccountingEntry(debit, walletdb);
686+
AddAccountingEntry(debit, &walletdb);
687687

688688
// Credit
689689
CAccountingEntry credit;
@@ -693,7 +693,7 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
693693
credit.nTime = nNow;
694694
credit.strOtherAccount = strFrom;
695695
credit.strComment = strComment;
696-
AddAccountingEntry(credit, walletdb);
696+
AddAccountingEntry(credit, &walletdb);
697697

698698
if (!walletdb.TxnCommit())
699699
return false;
@@ -2512,9 +2512,16 @@ void CWallet::ListAccountCreditDebit(const std::string& strAccount, std::list<CA
25122512
return walletdb.ListAccountCreditDebit(strAccount, entries);
25132513
}
25142514

2515-
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB & pwalletdb)
2515+
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry)
25162516
{
2517-
if (!pwalletdb.WriteAccountingEntry_Backend(acentry))
2517+
CWalletDB walletdb(strWalletFile);
2518+
2519+
return AddAccountingEntry(acentry, &walletdb);
2520+
}
2521+
2522+
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwalletdb)
2523+
{
2524+
if (!pwalletdb->WriteAccountingEntry_Backend(acentry))
25182525
return false;
25192526

25202527
laccentries.push_back(acentry);

src/wallet/wallet.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,8 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
777777
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CConnman* connman);
778778

779779
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries);
780-
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB & pwalletdb);
780+
bool AddAccountingEntry(const CAccountingEntry&);
781+
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB *pwalletdb);
781782

782783
static CFeeRate minTxFee;
783784
static CFeeRate fallbackFee;

0 commit comments

Comments
 (0)