aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-03-13 17:15:28 -0400
committerGavin Andresen <gavinandresen@gmail.com>2011-03-13 17:15:28 -0400
commitdfd059173d911f173e67d8a384265663fb5537b0 (patch)
treeb7b49ff117ff3940ee22cc5bf754989b7a11de38
parentb931ed8563eff9021ce3b1a05d8e6bc21117dc71 (diff)
parenta14bf1946dfade7c615cd41924c7cd41abdbc119 (diff)
Merge branch 'subcent-change' of https://github.com/tcatm/bitcoin
-rw-r--r--main.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/main.cpp b/main.cpp
index 50562b765f..7ddb24146c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3759,16 +3759,16 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<
int64 n = pcoin->GetCredit();
if (n <= 0)
continue;
- if (n < nTargetValue)
- {
- vValue.push_back(make_pair(n, pcoin));
- nTotalLower += n;
- }
- else if (n == nTargetValue)
+ if (n == nTargetValue)
{
setCoinsRet.insert(pcoin);
return true;
}
+ else if (n < nTargetValue + CENT)
+ {
+ vValue.push_back(make_pair(n, pcoin));
+ nTotalLower += n;
+ }
else if (n < nLowestLarger)
{
nLowestLarger = n;
@@ -3777,7 +3777,14 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<
}
}
- if (nTotalLower < nTargetValue)
+ if (nTotalLower == nTargetValue || nTotalLower == nTargetValue + CENT)
+ {
+ for (int i = 0; i < vValue.size(); ++i)
+ setCoinsRet.insert(vValue[i].second);
+ return true;
+ }
+
+ if (nTotalLower < nTargetValue + (pcoinLowestLarger ? CENT : 0))
{
if (pcoinLowestLarger == NULL)
return false;
@@ -3785,6 +3792,9 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<
return true;
}
+ if (nTotalLower >= nTargetValue + CENT)
+ nTargetValue += CENT;
+
// Solve subset sum by stochastic approximation
sort(vValue.rbegin(), vValue.rend());
vector<char> vfIncluded;