Skip to content

Commit 1bf9dc4

Browse files
committed
wallet: unify GetUnspentCredit with GetCredit
1 parent 9f2ae47 commit 1bf9dc4

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/wallet/wallet.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,37 +1297,24 @@ CAmount CWalletTx::GetUnspentCredit(const isminefilter& filter) const
12971297
if (GetBlocksToMaturity() > 0)
12981298
return 0;
12991299

1300-
CAmount credit = 0;
1301-
if (filter & ISMINE_SPENDABLE) {
1302-
credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE, false, true);
1303-
}
1304-
if (filter & ISMINE_WATCH_ONLY) {
1305-
credit += GetCachableAmount(CREDIT, ISMINE_WATCH_ONLY, false, true);
1306-
}
1307-
if (filter & ISMINE_COLD) {
1308-
credit += GetCachableAmount(CREDIT, ISMINE_COLD, false, true);
1309-
}
1310-
if (filter & ISMINE_SPENDABLE_DELEGATED) {
1311-
credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE_DELEGATED, false, true);
1312-
}
1313-
return credit;
1300+
return GetCredit(filter, false, true);
13141301
}
13151302

1316-
CAmount CWalletTx::GetCredit(const isminefilter& filter) const
1303+
CAmount CWalletTx::GetCredit(const isminefilter& filter, bool recalculate, bool fUnspent) const
13171304
{
13181305
CAmount credit = 0;
13191306
if (filter & ISMINE_SPENDABLE) {
13201307
// GetBalance can assume transactions in mapWallet won't change
1321-
credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE);
1308+
credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE, recalculate, fUnspent);
13221309
}
13231310
if (filter & ISMINE_WATCH_ONLY) {
1324-
credit += GetCachableAmount(CREDIT, ISMINE_WATCH_ONLY);
1311+
credit += GetCachableAmount(CREDIT, ISMINE_WATCH_ONLY, recalculate, fUnspent);
13251312
}
13261313
if (filter & ISMINE_COLD) {
1327-
credit += GetCachableAmount(CREDIT, ISMINE_COLD);
1314+
credit += GetCachableAmount(CREDIT, ISMINE_COLD, recalculate, fUnspent);
13281315
}
13291316
if (filter & ISMINE_SPENDABLE_DELEGATED) {
1330-
credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE_DELEGATED);
1317+
credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE_DELEGATED, recalculate, fUnspent);
13311318
}
13321319
return credit;
13331320
}

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ class CWalletTx : public CMerkleTx
917917

918918
//! filter decides which addresses will count towards the debit
919919
CAmount GetDebit(const isminefilter& filter) const;
920-
CAmount GetCredit(const isminefilter& filter) const;
920+
CAmount GetCredit(const isminefilter& filter, bool recalculate = false, bool fUnspent = false) const;
921921
CAmount GetUnspentCredit(const isminefilter& filter) const;
922922
CAmount GetImmatureCredit(bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE_ALL) const;
923923
CAmount GetAvailableCredit(bool fUseCache = true) const;

0 commit comments

Comments
 (0)