Skip to content

Commit faef293

Browse files
author
MarcoFalke
committed
[wallet] Add high transaction fee warnings
1 parent 24f72e9 commit faef293

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/init.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -951,10 +951,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
951951
if (mapArgs.count("-minrelaytxfee"))
952952
{
953953
CAmount n = 0;
954-
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
955-
::minRelayTxFee = CFeeRate(n);
956-
else
954+
if (!ParseMoney(mapArgs["-minrelaytxfee"], n))
957955
return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"]));
956+
// High fee check is done afterward in CWallet::ParameterInteraction()
957+
::minRelayTxFee = CFeeRate(n);
958958
}
959959

960960
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !Params().RequireStandard());

src/ui_interface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ void InitWarning(const std::string& str)
1818
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
1919
}
2020

21+
std::string AmountHighWarn(const std::string& optname)
22+
{
23+
return strprintf(_("%s is set very high!"), optname);
24+
}
25+
2126
std::string AmountErrMsg(const char* const optname, const std::string& strValue)
2227
{
2328
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);

src/ui_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void InitWarning(const std::string& str);
112112
/** Show error message **/
113113
bool InitError(const std::string& str);
114114

115+
std::string AmountHighWarn(const std::string& optname);
116+
115117
std::string AmountErrMsg(const char* const optname, const std::string& strValue);
116118

117119
extern CClientUIInterface uiInterface;

src/wallet/wallet.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,21 +3485,28 @@ bool CWallet::ParameterInteraction()
34853485
if (GetArg("-prune", 0) && GetBoolArg("-rescan", false))
34863486
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
34873487

3488+
if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB)
3489+
InitWarning(AmountHighWarn("-minrelaytxfee") + " " +
3490+
_("The wallet will avoid paying less than the minimum relay fee."));
3491+
34883492
if (mapArgs.count("-mintxfee"))
34893493
{
34903494
CAmount n = 0;
3491-
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
3492-
CWallet::minTxFee = CFeeRate(n);
3493-
else
3495+
if (!ParseMoney(mapArgs["-mintxfee"], n))
34943496
return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
3497+
if (n > HIGH_TX_FEE_PER_KB)
3498+
InitWarning(AmountHighWarn("-mintxfee") + " " +
3499+
_("This is the minimum transaction fee you pay on every transaction."));
3500+
CWallet::minTxFee = CFeeRate(n);
34953501
}
34963502
if (mapArgs.count("-fallbackfee"))
34973503
{
34983504
CAmount nFeePerK = 0;
34993505
if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK))
35003506
return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"]));
35013507
if (nFeePerK > HIGH_TX_FEE_PER_KB)
3502-
InitWarning(_("-fallbackfee is set very high! This is the transaction fee you may pay when fee estimates are not available."));
3508+
InitWarning(AmountHighWarn("-fallbackfee") + " " +
3509+
_("This is the transaction fee you may pay when fee estimates are not available."));
35033510
CWallet::fallbackFee = CFeeRate(nFeePerK);
35043511
}
35053512
if (mapArgs.count("-paytxfee"))
@@ -3508,7 +3515,9 @@ bool CWallet::ParameterInteraction()
35083515
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
35093516
return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
35103517
if (nFeePerK > HIGH_TX_FEE_PER_KB)
3511-
InitWarning(_("-paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
3518+
InitWarning(AmountHighWarn("-paytxfee") + " " +
3519+
_("This is the transaction fee you will pay if you send a transaction."));
3520+
35123521
payTxFee = CFeeRate(nFeePerK, 1000);
35133522
if (payTxFee < ::minRelayTxFee)
35143523
{

0 commit comments

Comments
 (0)