aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-11-09 19:47:07 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-11-09 19:47:07 +0000
commite2a186af10d81a0e27b2e7c34783711d65caeae7 (patch)
tree166a47e465ecd961b6f7b52f9c22d307ecfb09d4 /main.cpp
parent461764cbbea5965ebbd248f221876743d7a9ccd4 (diff)
SelectCoins first pass tries not to use coins with less than 6 confirmations
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@177 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index 904c2b8f76..190cd4b296 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3400,7 +3400,7 @@ int64 GetBalance()
}
-bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
+bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<CWalletTx*>& setCoinsRet)
{
setCoinsRet.clear();
@@ -3422,6 +3422,11 @@ bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
{
if (!pcoin->IsFinal() || pcoin->fSpent || !pcoin->IsConfirmed())
continue;
+
+ int nDepth = pcoin->GetDepthInMainChain();
+ if (nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs))
+ continue;
+
int64 n = pcoin->GetCredit();
if (n <= 0)
continue;
@@ -3506,6 +3511,13 @@ bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
return true;
}
+bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
+{
+ return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet) ||
+ SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet) ||
+ SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet));
+}
+