[wallet] GetBalance can take a min_depth argument.

This commit is contained in:
John Newbery 2018-06-27 14:11:21 -04:00
parent 0f3d6e9ab7
commit cf15761f6d
2 changed files with 3 additions and 3 deletions

View file

@ -2139,7 +2139,7 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman
*/
CAmount CWallet::GetBalance(const isminefilter& filter) const
CAmount CWallet::GetBalance(const isminefilter& filter, const int min_depth) const
{
CAmount nTotal = 0;
{
@ -2147,7 +2147,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);
}
}

View file

@ -943,7 +943,7 @@ public:
void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override;
// ResendWalletTransactionsBefore may only be called if fBroadcastTransactions!
std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman);
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;