From 5dd21ca6252227b510c40032735b08f00c0e4454 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Wed, 27 Jun 2018 14:11:21 -0400 Subject: [PATCH] [wallet] GetBalance can take a min_depth argument. (cherry picked from commit cf15761f6d4526d205126fbf5f088ac8edebeb57) --- src/wallet/wallet.cpp | 4 ++-- src/wallet/wallet.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index be3b44449..78ba9a254 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3129,7 +3129,7 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime) */ -CAmount CWallet::GetBalance(const isminefilter& filter) const +CAmount CWallet::GetBalance(const isminefilter& filter, const int min_depth) const { CAmount nTotal = 0; { @@ -3137,7 +3137,7 @@ CAmount CWallet::GetBalance(const isminefilter& filter) const for (const auto& entry : mapWallet) { const CWalletTx* pcoin = &entry.second; - if (pcoin->IsTrusted()) { + if (pcoin->IsTrusted() && pcoin->GetDepthInMainChain() >= min_depth) { nTotal += pcoin->GetAvailableCredit(true, filter); } } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index a661313c2..53dfcf1f4 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1177,7 +1177,7 @@ public: void ReacceptWalletTransactions(); void ResendWalletTransactions(int64_t nBestBlockTime); std::vector ResendWalletTransactionsBefore(int64_t nTime); - CAmount GetBalance(const isminefilter& filter=ISMINE_SPENDABLE) const; + CAmount GetBalance(const isminefilter& filter=ISMINE_SPENDABLE, const int min_depth=0) const; CAmount GetUnconfirmedBalance() const; CAmount GetImmatureBalance() const; CAmount GetUnconfirmedWatchOnlyBalance() const;