diff options
author | Alex Morcos <morcos@chaincode.com> | 2016-03-17 12:48:05 -0400 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-03-23 15:11:22 +0100 |
commit | 19866c1ffcb860bc2980e00e956685b9a8f96529 (patch) | |
tree | 25b380a9564e729acbbc48904a6300cb0d7c5f71 /src | |
parent | f04f4fd2eed581a5e287d14036d790cf2badcbe6 (diff) | |
download | bitcoin-19866c1ffcb860bc2980e00e956685b9a8f96529.tar.xz |
Fix calculation of balances and available coins.
No longer consider coins which aren't in our mempool.
Add test for regression in abandonconflict.py
Github-Pull: #7715
Rebased-From: 68d4282774d6a60c609301cddad0b652f16df4d9
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/wallet.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fca3d52f4a..71f3091489 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1576,7 +1576,7 @@ CAmount CWallet::GetUnconfirmedBalance() const for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; - if (!CheckFinalTx(*pcoin) || (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0)) + if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) nTotal += pcoin->GetAvailableCredit(); } } @@ -1621,7 +1621,7 @@ CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; - if (!CheckFinalTx(*pcoin) || (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0)) + if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) nTotal += pcoin->GetAvailableWatchOnlyCredit(); } } @@ -1666,6 +1666,11 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const if (nDepth < 0) continue; + // We should not consider coins which aren't at least in our mempool + // It's possible for these to be conflicted via ancestors which we may never be able to detect + if (nDepth == 0 && !pcoin->InMempool()) + continue; + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { isminetype mine = IsMine(pcoin->vout[i]); if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO && |