aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAlSzacrel <alszacrel@web.de>2014-09-13 02:09:18 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-12-08 10:25:58 +0100
commit96e8d120336cf4312cd5f42ba2f9aff17d4ad414 (patch)
tree9b2702948b636f36f5472dac8519771ac265ee2a /src/wallet/wallet.cpp
parentb2d7ada3727f026ccd83d3d64c75aab660d8053e (diff)
downloadbitcoin-96e8d120336cf4312cd5f42ba2f9aff17d4ad414.tar.xz
Coinselection prunes extraneous inputs from ApproximateBestSubset
This is a combination of 3 commits. - Coinselection prunes extraneous inputs from ApproximateBestSubset A further pass over the available inputs has been added to ApproximateBestSubset after a candidate set has been found. It will prune any extraneous inputs in the selected subset, in order to decrease the number of input and the resulting change. - Moved set reduction to the end of ApproximateBestSubset to reduce performance impact - Added a test for the pruning of extraneous inputs after ApproximateBestSet Github-Pull: #4906 Rebased-From: 5c03483e26ab414d22ef192691b2336c1bb3cb02 af9510e0374443b093d633a91c4f1f8bf5071292 fc0f52d78085b6ef97d6821fc7592326c2d9b495
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index d23d54e678..a262769c4d 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1632,6 +1632,16 @@ 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;
+ }
+ }
}
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,