Merge #8486: [wallet] Add high transaction fee warnings

faef293 [wallet] Add high transaction fee warnings (MarcoFalke)
This commit is contained in:
Wladimir J. van der Laan 2016-09-26 13:55:04 +02:00 committed by Alexander Block
parent 8edc2a78cb
commit d87c156f19
4 changed files with 24 additions and 8 deletions

View File

@ -1119,10 +1119,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (mapArgs.count("-minrelaytxfee")) if (mapArgs.count("-minrelaytxfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0) if (!ParseMoney(mapArgs["-minrelaytxfee"], n))
::minRelayTxFee = CFeeRate(n);
else
return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"])); return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"]));
// High fee check is done afterward in CWallet::ParameterInteraction()
::minRelayTxFee = CFeeRate(n);
} }
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !Params().RequireStandard()); fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !Params().RequireStandard());

View File

@ -18,6 +18,11 @@ void InitWarning(const std::string& str)
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING); uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
} }
std::string AmountHighWarn(const std::string& optname)
{
return strprintf(_("%s is set very high!"), optname);
}
std::string AmountErrMsg(const char* const optname, const std::string& strValue) std::string AmountErrMsg(const char* const optname, const std::string& strValue)
{ {
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue); return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);

View File

@ -125,6 +125,8 @@ void InitWarning(const std::string& str);
/** Show error message **/ /** Show error message **/
bool InitError(const std::string& str); bool InitError(const std::string& str);
std::string AmountHighWarn(const std::string& optname);
std::string AmountErrMsg(const char* const optname, const std::string& strValue); std::string AmountErrMsg(const char* const optname, const std::string& strValue);
extern CClientUIInterface uiInterface; extern CClientUIInterface uiInterface;

View File

@ -4779,13 +4779,19 @@ bool CWallet::ParameterInteraction()
if (GetArg("-prune", 0) && GetBoolArg("-rescan", false)) if (GetArg("-prune", 0) && GetBoolArg("-rescan", false))
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again.")); return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-minrelaytxfee") + " " +
_("The wallet will avoid paying less than the minimum relay fee."));
if (mapArgs.count("-mintxfee")) if (mapArgs.count("-mintxfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0) if (!ParseMoney(mapArgs["-mintxfee"], n))
CWallet::minTxFee = CFeeRate(n);
else
return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"])); return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
if (n > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-mintxfee") + " " +
_("This is the minimum transaction fee you pay on every transaction."));
CWallet::minTxFee = CFeeRate(n);
} }
if (mapArgs.count("-fallbackfee")) if (mapArgs.count("-fallbackfee"))
{ {
@ -4793,7 +4799,8 @@ bool CWallet::ParameterInteraction()
if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK)) if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK))
return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"])); return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"]));
if (nFeePerK > HIGH_TX_FEE_PER_KB) if (nFeePerK > HIGH_TX_FEE_PER_KB)
InitWarning(_("-fallbackfee is set very high! This is the transaction fee you may pay when fee estimates are not available.")); InitWarning(AmountHighWarn("-fallbackfee") + " " +
_("This is the transaction fee you may pay when fee estimates are not available."));
CWallet::fallbackFee = CFeeRate(nFeePerK); CWallet::fallbackFee = CFeeRate(nFeePerK);
} }
if (mapArgs.count("-paytxfee")) if (mapArgs.count("-paytxfee"))
@ -4802,7 +4809,9 @@ bool CWallet::ParameterInteraction()
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK)) if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"])); return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
if (nFeePerK > HIGH_TX_FEE_PER_KB) if (nFeePerK > HIGH_TX_FEE_PER_KB)
InitWarning(_("-paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.")); InitWarning(AmountHighWarn("-paytxfee") + " " +
_("This is the transaction fee you will pay if you send a transaction."));
payTxFee = CFeeRate(nFeePerK, 1000); payTxFee = CFeeRate(nFeePerK, 1000);
if (payTxFee < ::minRelayTxFee) if (payTxFee < ::minRelayTxFee)
{ {