[wallet] GetBalance can take a min_depth argument.

pull/585/head
John Newbery 6 years ago
parent 0f3d6e9ab7
commit cf15761f6d

@ -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; CAmount nTotal = 0;
{ {
@ -2147,7 +2147,7 @@ CAmount CWallet::GetBalance(const isminefilter& filter) const
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const CWalletTx* pcoin = &entry.second; const CWalletTx* pcoin = &entry.second;
if (pcoin->IsTrusted()) { if (pcoin->IsTrusted() && pcoin->GetDepthInMainChain() >= min_depth) {
nTotal += pcoin->GetAvailableCredit(true, filter); nTotal += pcoin->GetAvailableCredit(true, filter);
} }
} }

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

Loading…
Cancel
Save