From 6b91ab15be32a8afc4d353fc6a62ca30671522d2 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 23 Oct 2013 23:44:46 +0400 Subject: [PATCH] Add -mininput=value option Allows user to set sultable input value limit --- src/init.cpp | 7 +++++++ src/main.cpp | 2 ++ src/main.h | 1 + src/rpcwallet.cpp | 1 + src/wallet.cpp | 2 +- src/wallet.h | 2 +- 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index a35efaf..80405c9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -265,6 +265,7 @@ std::string HelpMessage() #endif " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n" + + " -mininput= " + _("When creating transactions, ignore inputs with value less than this (default: 0.01)") + "\n" + #ifdef QT_GUI " -server " + _("Accept command line and JSON-RPC commands") + "\n" + #endif @@ -467,6 +468,12 @@ bool AppInit2() InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.")); } + if (mapArgs.count("-mininput")) + { + if (!ParseMoney(mapArgs["-mininput"], nMinimumInputValue)) + return InitError(strprintf(_("Invalid amount for -mininput=: '%s'"), mapArgs["-mininput"].c_str())); + } + // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log std::string strDataDir = GetDataDir().string(); diff --git a/src/main.cpp b/src/main.cpp index 14339a3..63700ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,6 +77,8 @@ const string strMessageMagic = "NovaCoin Signed Message:\n"; // Settings int64 nTransactionFee = MIN_TX_FEE; +int64 nMinimumInputValue = MIN_TX_FEE; + bool fStakeUsePooledKeys = false; extern enum Checkpoints::CPMode CheckpointsMode; diff --git a/src/main.h b/src/main.h index 9680bee..ed202c4 100644 --- a/src/main.h +++ b/src/main.h @@ -87,6 +87,7 @@ extern std::map mapOrphanBlocks; // Settings extern int64 nTransactionFee; +extern int64 nMinimumInputValue; extern bool fStakeUsePooledKeys; extern unsigned int nDerivationMethodIndex; diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 47ebec0..b61581e 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -87,6 +87,7 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); + obj.push_back(Pair("mininput", ValueFromAmount(nMinimumInputValue))); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); diff --git a/src/wallet.cpp b/src/wallet.cpp index 67a50ab..5894dca 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1050,7 +1050,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const continue; for (unsigned int i = 0; i < pcoin->vout.size(); i++) - if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) && pcoin->vout[i].nValue > 0 && + if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) && pcoin->vout[i].nValue >= nMinimumInputValue && (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) vCoins.push_back(COutput(pcoin, i, pcoin->GetDepthInMainChain())); diff --git a/src/wallet.h b/src/wallet.h index f52dc59..b0c557e 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -234,7 +234,7 @@ public: bool IsMine(const CTransaction& tx) const { BOOST_FOREACH(const CTxOut& txout, tx.vout) - if (IsMine(txout)) + if (IsMine(txout) && txout.nValue >= nMinimumInputValue) return true; return false; } -- 1.7.1