Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accept automatic fees up to new "maxtxfee" parameter

  • Loading branch information...
commit 6cfc675f31d20f6f3fdf89af8cd264143dabec19 1 parent d5cdfa4
Luke-Jr authored
38 src/bitcoinrpc.cpp
View
@@ -528,6 +528,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", pwalletMain->GetKeyPoolSize()));
obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee)));
+ obj.push_back(Pair("maxtxfee", ValueFromAmount(nTransactionFeeMax)));
obj.push_back(Pair("forcetxfee", fForceFee));
if (pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000));
@@ -718,26 +719,42 @@ Value settxfee(const Array& params, bool fHelp)
{
if (GetBoolArg("-nosafefees"))
{
- if (fHelp || params.size() < 1 || params.size() > 2)
+ if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
- "settxfee <amount> [force]\n"
- "<amount> is a real and is rounded to the nearest 0.00000001\n"
+ "settxfee <default amount> [maximum amount] [force]\n"
+ "<default amount> specifies the transaction fee to include in all transactions\n"
+ "[maximum amount] specifies the upper limit of how high the client will automatically\n"
+ " adjust your fee as it deems necessary\n"
"[force] is a boolean that enables sending less than the safe minimum fee");
}
else
- if (fHelp || params.size() < 1 || params.size() > 1)
+ if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "settxfee <amount>\n"
- "<amount> is a real and is rounded to the nearest 0.00000001");
+ "settxfee <default amount> [maximum amount]\n"
+ "<default amount> specifies the transaction fee to include in all transactions\n"
+ "[maximum amount] specifies the upper limit of how high the client will automatically\n"
+ " adjust your fee as it deems necessary");
- // Amount
+ // Amounts
int64 nAmount = 0;
if (params[0].get_real() != 0.0)
nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts
- nTransactionFee = nAmount;
if (params.size() > 1)
- fForceFee = params[1].get_bool();
+ {
+ int64 nAmountMax;
+ if (params[1].get_real() == 0.0)
+ nAmountMax = 0;
+ else
+ nAmountMax = AmountFromValue(params[1]);
+ if (nAmountMax < nAmount)
+ throw runtime_error("Maximum fee, if provided, should be at least the amount of the default fee");
+ nTransactionFeeMax = nAmountMax;
+ }
+ nTransactionFee = nAmount;
+ if (params.size() > 2)
+ fForceFee = params[2].get_bool();
+
return true;
}
@@ -2938,7 +2955,8 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "settxfee" && n > 0) ConvertTo<double>(params[0]);
- if (strMethod == "settxfee" && n > 1) ConvertTo<bool>(params[1]);
+ if (strMethod == "settxfee" && n > 1) ConvertTo<double>(params[1]);
+ if (strMethod == "settxfee" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "getreceivedbyaccount" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "listreceivedbyaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);
6 src/init.cpp
View
@@ -654,6 +654,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("-maxtxfee"))
+ {
+ if (!ParseMoney(mapArgs["-maxtxfee"], nTransactionFeeMax))
+ return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s'"), mapArgs["-maxtxfee"].c_str()));
+ }
+
//
// Start the node
//
1  src/main.cpp
View
@@ -55,6 +55,7 @@ int64 nHPSTimerStart;
// Settings
int64 nTransactionFee = 0;
+int64 nTransactionFeeMax = CENT;
bool fForceFee = false;
1  src/main.h
View
@@ -70,6 +70,7 @@ extern unsigned char pchMessageStart[4];
// Settings
extern int64 nTransactionFee;
+extern int64 nTransactionFeeMax;
extern bool fForceFee;
3  src/noui.cpp
View
@@ -6,6 +6,7 @@
#include <string>
#include "init.h"
+#include "main.h"
int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style)
{
@@ -16,7 +17,7 @@ int ThreadSafeMessageBox(const std::string& message, const std::string& caption,
bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
{
- return false;
+ return nFeeRequired == nTransactionFee || nFeeRequired <= nTransactionFeeMax;
}
void MainFrameRepaint()
Please sign in to comment.
Something went wrong with that request. Please try again.