OSDN Git Service

Add option to avoid spending unconfirmed change
authormonacoinproject <monacoinproject@gmail.com>
Sun, 6 Apr 2014 15:23:56 +0000 (00:23 +0900)
committermonacoinproject <monacoinproject@gmail.com>
Sun, 6 Apr 2014 15:23:56 +0000 (00:23 +0900)
Conflicts:
src/init.cpp
src/wallet.cpp
src/wallet.h

src/init.cpp
src/wallet.cpp
src/wallet.h

index ec5f47d..cb9a4ab 100644 (file)
@@ -358,6 +358,7 @@ std::string HelpMessage()
         "  -rpcthreads=<n>        " + _("Set the number of threads to service RPC calls (default: 4)") + "\n" +
         "  -blocknotify=<cmd>     " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
         "  -walletnotify=<cmd>    " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n" +
+        "  -spendzeroconfchange   " + _("Spend unconfirmed change when sending transactions (default: 1)") + "\n" +
         "  -alertnotify=<cmd>     " + _("Execute command when a relevant alert is received (%s in cmd is replaced by message)") + "\n" +
         "  -upgradewallet         " + _("Upgrade wallet to latest format") + "\n" +
         "  -keypool=<n>           " + _("Set key pool size to <n> (default: 100)") + "\n" +
@@ -627,6 +628,7 @@ bool AppInit2(boost::thread_group& threadGroup)
         if (nTransactionFee > 0.25 * COIN)
             InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
     }
+    bSpendZeroConfChange = GetArg("-spendzeroconfchange", true);
 
     if (mapArgs.count("-mininput"))
     {
index cd5a3f9..da288bd 100644 (file)
@@ -14,6 +14,8 @@
 using namespace std;
 
 
+bool bSpendZeroConfChange = true;
+
 //////////////////////////////////////////////////////////////////////////////
 //
 // mapWallet
@@ -1170,7 +1172,7 @@ bool CWallet::SelectCoins(int64 nTargetValue, set<pair<const CWalletTx*,unsigned
 
     return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
             SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
-            SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet));
+            (bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet)));
 }
 
 
index cd1fb34..d7e5c56 100644 (file)
@@ -18,6 +18,8 @@
 #include "util.h"
 #include "walletdb.h"
 
+extern bool bSpendZeroConfChange;
+
 class CAccountingEntry;
 class CWalletTx;
 class CReserveKey;