@@ -907,6 +907,16 @@ void InitParameterInteraction()
907907 }
908908}
909909
910+ static std::string ResolveErrMsg (const char * const optname, const std::string& strBind)
911+ {
912+ return strprintf (_ (" Cannot resolve -%s address: '%s'" ), optname, strBind);
913+ }
914+
915+ static std::string AmountErrMsg (const char * const optname, const std::string& strValue)
916+ {
917+ return strprintf (_ (" Invalid amount for -%s=<amount>: '%s'" ), optname, strValue);
918+ }
919+
910920void InitLogging ()
911921{
912922 fPrintToConsole = GetBoolArg (" -printtoconsole" , false );
@@ -1003,7 +1013,7 @@ bool AppInit2()
10031013 if (ParseMoney (mapArgs[" -minrelaytxfee" ], n) && n > 0 )
10041014 ::minRelayTxFee = CFeeRate (n);
10051015 else
1006- return InitError (strprintf ( _ ( " Invalid amount for - minrelaytxfee=<amount>: '%s' " ) , mapArgs[" -minrelaytxfee" ]));
1016+ return InitError (AmountErrMsg ( " minrelaytxfee" , mapArgs[" -minrelaytxfee" ]));
10071017 }
10081018
10091019#ifdef ENABLE_WALLET
@@ -1012,12 +1022,12 @@ bool AppInit2()
10121022 if (ParseMoney (mapArgs[" -mintxfee" ], n) && n > 0 )
10131023 CWallet::minTxFee = CFeeRate (n);
10141024 else
1015- return InitError (strprintf ( _ ( " Invalid amount for - mintxfee=<amount>: '%s' " ) , mapArgs[" -mintxfee" ]));
1025+ return InitError (AmountErrMsg ( " mintxfee" , mapArgs[" -mintxfee" ]));
10161026 }
10171027 if (mapArgs.count (" -paytxfee" )) {
10181028 CAmount nFeePerK = 0 ;
10191029 if (!ParseMoney (mapArgs[" -paytxfee" ], nFeePerK))
1020- return InitError (strprintf ( _ ( " Invalid amount for - paytxfee=<amount>: '%s' " ) , mapArgs[" -paytxfee" ]));
1030+ return InitError (AmountErrMsg ( " paytxfee" , mapArgs[" -paytxfee" ]));
10211031 if (nFeePerK > nHighTransactionFeeWarning)
10221032 InitWarning (_ (" Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction." ));
10231033 payTxFee = CFeeRate (nFeePerK, 1000 );
@@ -1029,7 +1039,7 @@ bool AppInit2()
10291039 if (mapArgs.count (" -maxtxfee" )) {
10301040 CAmount nMaxFee = 0 ;
10311041 if (!ParseMoney (mapArgs[" -maxtxfee" ], nMaxFee))
1032- return InitError (strprintf ( _ ( " Invalid amount for - maxtxfee=<amount>: '%s' " ) , mapArgs[" -maxtxfee" ]));
1042+ return InitError (AmountErrMsg ( " maxtxfee" , mapArgs[" -maxtxfee" ]));
10331043 if (nMaxFee > nHighTransactionMaxFeeWarning)
10341044 InitWarning (_ (" Warning: -maxtxfee is set very high! Fees this large could be paid on a single transaction." ));
10351045 maxTxFee = nMaxFee;
@@ -1377,13 +1387,13 @@ bool AppInit2()
13771387 for (std::string strBind : mapMultiArgs[" -bind" ]) {
13781388 CService addrBind;
13791389 if (!Lookup (strBind.c_str (), addrBind, GetListenPort (), false ))
1380- return InitError (strprintf ( _ ( " Cannot resolve - bind address: '%s' " ) , strBind));
1390+ return InitError (ResolveErrMsg ( " bind" , strBind));
13811391 fBound |= Bind (addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
13821392 }
13831393 for (std::string strBind : mapMultiArgs[" -whitebind" ]) {
13841394 CService addrBind;
13851395 if (!Lookup (strBind.c_str (), addrBind, 0 , false ))
1386- return InitError (strprintf ( _ ( " Cannot resolve - whitebind address: '%s' " ) , strBind));
1396+ return InitError (ResolveErrMsg ( " whitebind" , strBind));
13871397 if (addrBind.GetPort () == 0 )
13881398 return InitError (strprintf (_ (" Need to specify a port with -whitebind: '%s'" ), strBind));
13891399 fBound |= Bind (addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST));
@@ -1404,7 +1414,7 @@ bool AppInit2()
14041414 if (Lookup (strAddr.c_str (), addrLocal, GetListenPort (), fNameLookup ) && addrLocal.IsValid ())
14051415 AddLocal (addrLocal,LOCAL_MANUAL);
14061416 else
1407- return InitError (strprintf ( _ ( " Cannot resolve - externalip address: '%s' " ) , strAddr));
1417+ return InitError (ResolveErrMsg ( " externalip" , strAddr));
14081418 }
14091419 }
14101420
0 commit comments