diff options
author | Murch <alszacrel@web.de> | 2015-12-07 00:15:36 +0100 |
---|---|---|
committer | Murch <alszacrel@web.de> | 2015-12-07 20:08:37 +0100 |
commit | fc0f52d78085b6ef97d6821fc7592326c2d9b495 (patch) | |
tree | a2de0198446bee8439bfdba90cb74efd0256817c /src/wallet/wallet.cpp | |
parent | af9510e0374443b093d633a91c4f1f8bf5071292 (diff) | |
download | bitcoin-fc0f52d78085b6ef97d6821fc7592326c2d9b495.tar.xz |
Added a test for the pruning of extraneous inputs after ApproximateBestSet
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f9e8a97ae6..a262769c4d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1605,7 +1605,7 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns bool fReachedTarget = false; for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++) { - for (unsigned int i = 0; i < vValue.size() && !fReachedTarget; i++) + for (unsigned int i = 0; i < vValue.size(); i++) { //The solver here uses a randomized algorithm, //the randomness serves no real security purpose but is just @@ -1625,6 +1625,8 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns nBest = nTotal; vfBest = vfIncluded; } + nTotal -= vValue[i].first; + vfIncluded[i] = false; } } } @@ -1634,11 +1636,11 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns //Reduces the approximate best subset by removing any inputs that are smaller than the surplus of nTotal beyond nTargetValue. for (unsigned int i = 0; i < vValue.size(); i++) { - if (vfBest[i] && (nBest - vValue[i].first) >= nTargetValue ) - { - vfBest[i] = false; - nBest -= vValue[i].first; - } + if (vfBest[i] && (nBest - vValue[i].first) >= nTargetValue ) + { + vfBest[i] = false; + nBest -= vValue[i].first; + } } } |