aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorChris Moore <dooglus@gmail.com>2012-04-07 12:45:39 -0700
committerLuke Dashjr <luke-jr+git@utopios.org>2012-06-04 16:36:46 +0000
commitd650f96d5f48a9cc458af9ef644f57973ca7f48b (patch)
treef3b66f551d46d82e99f2e51b773857b7f9b43ebc /src/wallet.cpp
parent4ce190a0157837df9a4a804f8e3f2941d1ffacf5 (diff)
downloadbitcoin-d650f96d5f48a9cc458af9ef644f57973ca7f48b.tar.xz
Preserve the shuffled order of coins with equal value to give more randomized coin selection.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 36dbe7aeb1..d190ad9242 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -17,6 +17,15 @@ using namespace std;
// mapWallet
//
+struct CompareValueOnly
+{
+ bool operator()(const pair<int64, pair<const CWalletTx*, unsigned int> >& t1,
+ const pair<int64, pair<const CWalletTx*, unsigned int> >& t2) const
+ {
+ return t1.first < t2.first;
+ }
+};
+
CPubKey CWallet::GenerateNewKey()
{
bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
@@ -980,7 +989,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
nTargetValue += CENT;
// Solve subset sum by stochastic approximation
- sort(vValue.rbegin(), vValue.rend());
+ sort(vValue.rbegin(), vValue.rend(), CompareValueOnly());
vector<char> vfIncluded;
vector<char> vfBest(vValue.size(), true);
int64 nBest = nTotalLower;