From 1cb0b13f0be9977d4682d7ce040ad8ce101f3333 Mon Sep 17 00:00:00 2001 From: Dmitry Saveliev Date: Tue, 16 Apr 2019 16:59:51 +0200 Subject: [PATCH] Ignore spent transaction in WalletExtension::GetRemoteStakingBalance Signed-off-by: Dmitry Saveliev --- src/esperanza/walletextension.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/esperanza/walletextension.cpp b/src/esperanza/walletextension.cpp index 930e40fc5a..f6aa099122 100644 --- a/src/esperanza/walletextension.cpp +++ b/src/esperanza/walletextension.cpp @@ -120,10 +120,17 @@ CAmount WalletExtension::GetRemoteStakingBalance() const { CAmount balance = 0; + const CCoinsViewCache &view = pcoinsTip.get(); // requires cs_main + for (const auto &it : m_enclosing_wallet.mapWallet) { const CWalletTx *const tx = &it.second; + const uint256 &hashTx = tx->GetHash(); - for (const auto &txout : tx->tx->vout) { + for (size_t i = 0; i < tx->tx->vout.size(); ++i) { + const CTxOut &txout = tx->tx->vout[i]; + if (m_enclosing_wallet.IsSpent(hashTx, i)) { + continue; + } if (::IsStakedRemotely(m_enclosing_wallet, txout.scriptPubKey)) { balance += txout.nValue; }