Skip to content

Commit

Permalink
Merge PIVX-Project#1376: [Init] Combine common error strings so trans…
Browse files Browse the repository at this point in the history
…lations can be shared

77998ed Combine common error strings so translations can be shared and reused (Luke Dashjr)

Pull request description:

  Backport of bitcoin#7257

  Adds helper methods for common translatable string outputs during init, end result is that the number of strings sent to Transifex is reduced/standardized.

  Based on top of PIVX-Project#1375

  Conflicts with PIVX-Project#1373 (this to be rebased after both PIVX-Project#1373 and PIVX-Project#1375 are merged)

ACKs for top commit:
  random-zebra:
    utACK 77998ed
  furszy:
    utACK 77998ed and merging..

Tree-SHA512: 9805b931829f76cbc34b43b7e6141b236d162bd0267342714222612b8e51cdc9d8b35e68971775bd7a489e95a3c4f9b533bbf1ecaa0e56b19a443ed308141c87
  • Loading branch information
furszy authored and akshaynexus committed Mar 13, 2020
1 parent 8d554df commit b8f934d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,16 @@ void InitParameterInteraction()
}
}

static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
{
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
}

static std::string AmountErrMsg(const char * const optname, const std::string& strValue)
{
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
}

void InitLogging()
{
fPrintToConsole = GetBoolArg("-printtoconsole", false);
Expand Down Expand Up @@ -1003,7 +1013,7 @@ bool AppInit2()
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
::minRelayTxFee = CFeeRate(n);
else
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"]));
return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"]));
}

#ifdef ENABLE_WALLET
Expand All @@ -1012,12 +1022,12 @@ bool AppInit2()
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
CWallet::minTxFee = CFeeRate(n);
else
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"]));
return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
}
if (mapArgs.count("-paytxfee")) {
CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"]));
return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
if (nFeePerK > nHighTransactionFeeWarning)
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
payTxFee = CFeeRate(nFeePerK, 1000);
Expand All @@ -1029,7 +1039,7 @@ bool AppInit2()
if (mapArgs.count("-maxtxfee")) {
CAmount nMaxFee = 0;
if (!ParseMoney(mapArgs["-maxtxfee"], nMaxFee))
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s'"), mapArgs["-maxtxfee"]));
return InitError(AmountErrMsg("maxtxfee", mapArgs["-maxtxfee"]));
if (nMaxFee > nHighTransactionMaxFeeWarning)
InitWarning(_("Warning: -maxtxfee is set very high! Fees this large could be paid on a single transaction."));
maxTxFee = nMaxFee;
Expand Down Expand Up @@ -1377,13 +1387,13 @@ bool AppInit2()
for (std::string strBind : mapMultiArgs["-bind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind));
return InitError(ResolveErrMsg("bind", strBind));
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
}
for (std::string strBind : mapMultiArgs["-whitebind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, 0, false))
return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind));
return InitError(ResolveErrMsg("whitebind", strBind));
if (addrBind.GetPort() == 0)
return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind));
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST));
Expand All @@ -1404,7 +1414,7 @@ bool AppInit2()
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
AddLocal(addrLocal,LOCAL_MANUAL);
else
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
return InitError(ResolveErrMsg("externalip", strAddr));
}
}

Expand Down

0 comments on commit b8f934d

Please sign in to comment.