Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add mininput to deal with dust spam.

By default, mininput is set to 0.0001. This means that create transaction will
ignore any transactions with an output value less than 0.0001. You can override
the default by passing in -mininput on startup or by calling setmininput.
  • Loading branch information...
commit fe85d48fc301412aee30764a84651b8ae8e7f31c 1 parent 1d8bff7
@coblee coblee authored committed
View
2  src/db.cpp
@@ -803,6 +803,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
#endif
if (strKey == "nTransactionFee") ssValue >> nTransactionFee;
+ if (strKey == "nMinimumInputValue") ssValue >> nMinimumInputValue;
if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors;
if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors;
if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray;
@@ -821,6 +822,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet)
printf("nFileVersion = %d\n", nFileVersion);
printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
+ printf("nMinimumInputValue = %"PRI64d"\n", nMinimumInputValue);
printf("fMinimizeToTray = %d\n", fMinimizeToTray);
printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
printf("fUseProxy = %d\n", fUseProxy);
View
10 src/init.cpp
@@ -186,6 +186,7 @@ bool AppInit2(int argc, char* argv[])
#endif
#endif
" -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") +
+ " -mininput=<amt> \t " + _("When creating transactions, ignore inputs with value less than this (default: 0.0001)\n") +
#ifdef GUI
" -server \t\t " + _("Accept command line and JSON-RPC commands\n") +
#endif
@@ -512,6 +513,15 @@ bool AppInit2(int argc, char* argv[])
wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION);
}
+ if (mapArgs.count("-mininput"))
+ {
+ if (!ParseMoney(mapArgs["-mininput"], nMinimumInputValue))
+ {
+ wxMessageBox(_("Invalid amount for -mininput=<amount>"), "Litecoin");
+ return false;
+ }
+ }
+
if (fHaveUPnP)
{
#if USE_UPNP
View
1  src/main.cpp
@@ -56,6 +56,7 @@ int64 nHPSTimerStart;
// Settings
int fGenerateBitcoins = false;
int64 nTransactionFee = 0;
+int64 nMinimumInputValue = CENT / 100;
int fLimitProcessors = false;
int nLimitProcessors = 1;
int fMinimizeToTray = true;
View
1  src/main.h
@@ -72,6 +72,7 @@ extern std::set<CWallet*> setpwalletRegistered;
// Settings
extern int fGenerateBitcoins;
extern int64 nTransactionFee;
+extern int64 nMinimumInputValue;
extern int fLimitProcessors;
extern int nLimitProcessors;
extern int fMinimizeToTray;
View
19 src/rpc.cpp
@@ -453,6 +453,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("testnet", fTestNet));
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee)));
+ obj.push_back(Pair("mininput", ValueFromAmount(nMinimumInputValue)));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
return obj;
}
@@ -651,6 +652,22 @@ Value settxfee(const Array& params, bool fHelp)
return true;
}
+Value setmininput(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() < 1 || params.size() > 1)
+ throw runtime_error(
+ "setmininput <amount>\n"
+ "<amount> is a real and is rounded to the nearest 0.00000001");
+
+ // Amount
+ int64 nAmount = 0;
+ if (params[0].get_real() != 0.0)
+ nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts
+
+ nMinimumInputValue = nAmount;
+ return true;
+}
+
Value sendtoaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 4)
@@ -2012,6 +2029,7 @@ pair<string, rpcfn_type> pCallTable[] =
make_pair("listaccounts", &listaccounts),
make_pair("settxfee", &settxfee),
make_pair("getmemorypool", &getmemorypool),
+ make_pair("setmininput", &setmininput),
};
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
@@ -2656,6 +2674,7 @@ int CommandLineRPC(int argc, char *argv[])
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "settxfee" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated
+ if (strMethod == "setmininput" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "getreceivedbyaccount" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "getreceivedbylabel" && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated
View
4 src/wallet.cpp
@@ -621,7 +621,9 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
int64 n = pcoin->vout[i].nValue;
- if (n <= 0)
+ // If output is less than minimum value, then don't include transaction.
+ // This is to help deal with dust spam clogging up create transactions.
+ if (n <= 0 || n < nMinimumInputValue)
continue;
pair<int64,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin,i));
Please sign in to comment.
Something went wrong with that request. Please try again.