Skip to content

Commit cf15761

Browse files
committed
[wallet] GetBalance can take a min_depth argument.
1 parent 0f3d6e9 commit cf15761

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,15 +2139,15 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman
21392139
*/
21402140

21412141

2142-
CAmount CWallet::GetBalance(const isminefilter& filter) const
2142+
CAmount CWallet::GetBalance(const isminefilter& filter, const int min_depth) const
21432143
{
21442144
CAmount nTotal = 0;
21452145
{
21462146
LOCK2(cs_main, cs_wallet);
21472147
for (const auto& entry : mapWallet)
21482148
{
21492149
const CWalletTx* pcoin = &entry.second;
2150-
if (pcoin->IsTrusted()) {
2150+
if (pcoin->IsTrusted() && pcoin->GetDepthInMainChain() >= min_depth) {
21512151
nTotal += pcoin->GetAvailableCredit(true, filter);
21522152
}
21532153
}

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
943943
void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override;
944944
// ResendWalletTransactionsBefore may only be called if fBroadcastTransactions!
945945
std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman);
946-
CAmount GetBalance(const isminefilter& filter=ISMINE_SPENDABLE) const;
946+
CAmount GetBalance(const isminefilter& filter=ISMINE_SPENDABLE, const int min_depth=0) const;
947947
CAmount GetUnconfirmedBalance() const;
948948
CAmount GetImmatureBalance() const;
949949
CAmount GetUnconfirmedWatchOnlyBalance() const;

0 commit comments

Comments
 (0)