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;