aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/error.cpp7
-rw-r--r--src/util/error.h6
-rw-r--r--src/util/system.cpp16
-rw-r--r--src/util/system.h2
4 files changed, 25 insertions, 6 deletions
diff --git a/src/util/error.cpp b/src/util/error.cpp
index 9edb7dc533..287476c0d3 100644
--- a/src/util/error.cpp
+++ b/src/util/error.cpp
@@ -36,12 +36,17 @@ std::string TransactionErrorString(const TransactionError err)
assert(false);
}
+std::string ResolveErrMsg(const std::string& optname, const std::string& strBind)
+{
+ return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, strBind);
+}
+
std::string AmountHighWarn(const std::string& optname)
{
return strprintf(_("%s is set very high!").translated, optname);
}
-std::string AmountErrMsg(const char* const optname, const std::string& strValue)
+std::string AmountErrMsg(const std::string& optname, const std::string& strValue)
{
return strprintf(_("Invalid amount for -%s=<amount>: '%s'").translated, optname, strValue);
}
diff --git a/src/util/error.h b/src/util/error.h
index 0fd474b962..7777cc0c5d 100644
--- a/src/util/error.h
+++ b/src/util/error.h
@@ -10,7 +10,7 @@
* string functions. Types and functions defined here should not require any
* outside dependencies.
*
- * Error types defined here can be used in different parts of the bitcoin
+ * Error types defined here can be used in different parts of the
* codebase, to avoid the need to write boilerplate code catching and
* translating errors passed across wallet/node/rpc/gui code boundaries.
*/
@@ -32,8 +32,10 @@ enum class TransactionError {
std::string TransactionErrorString(const TransactionError error);
+std::string ResolveErrMsg(const std::string& optname, const std::string& strBind);
+
std::string AmountHighWarn(const std::string& optname);
-std::string AmountErrMsg(const char* const optname, const std::string& strValue);
+std::string AmountErrMsg(const std::string& optname, const std::string& strValue);
#endif // BITCOIN_UTIL_ERROR_H
diff --git a/src/util/system.cpp b/src/util/system.cpp
index f8bcc45a6a..c925dec253 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -748,8 +748,9 @@ const fs::path &GetDataDir(bool fNetSpecific)
// this function
if (!path.empty()) return path;
- if (gArgs.IsArgSet("-datadir")) {
- path = fs::system_complete(gArgs.GetArg("-datadir", ""));
+ std::string datadir = gArgs.GetArg("-datadir", "");
+ if (!datadir.empty()) {
+ path = fs::system_complete(datadir);
if (!fs::is_directory(path)) {
path = "";
return path;
@@ -768,6 +769,12 @@ const fs::path &GetDataDir(bool fNetSpecific)
return path;
}
+bool CheckDataDirOption()
+{
+ std::string datadir = gArgs.GetArg("-datadir", "");
+ return datadir.empty() || fs::is_directory(fs::system_complete(datadir));
+}
+
void ClearDatadirCache()
{
LOCK(csPathCached);
@@ -937,7 +944,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
// If datadir is changed in .conf file:
ClearDatadirCache();
- if (!fs::is_directory(GetDataDir(false))) {
+ if (!CheckDataDirOption()) {
error = strprintf("specified data directory \"%s\" does not exist.", gArgs.GetArg("-datadir", "").c_str());
return false;
}
@@ -1205,6 +1212,9 @@ int64_t GetStartupTime()
fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific)
{
+ if (path.is_absolute()) {
+ return path;
+ }
return fs::absolute(path, GetDataDir(net_specific));
}
diff --git a/src/util/system.h b/src/util/system.h
index 75e8096826..908a3c407d 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -71,6 +71,8 @@ fs::path GetDefaultDataDir();
// The blocks directory is always net specific.
const fs::path &GetBlocksDir();
const fs::path &GetDataDir(bool fNetSpecific = true);
+// Return true if -datadir option points to a valid directory or is not specified.
+bool CheckDataDirOption();
/** Tests only */
void ClearDatadirCache();
fs::path GetConfigFile(const std::string& confPath);