aboutsummaryrefslogtreecommitdiff
path: root/src/util/system.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2019-04-28 19:08:26 -0400
committerRussell Yanofsky <russ@yanofsky.org>2020-07-11 05:41:12 -0400
commit9c69cfe4c54e38edd2f54303be2f8a53dcf5bad8 (patch)
tree3480cdc4b02a6c893b0f756b8a31319351dc6b2c /src/util/system.h
parenteb682c5700e7a9176d0104d470b83ff9aa3589e8 (diff)
downloadbitcoin-9c69cfe4c54e38edd2f54303be2f8a53dcf5bad8.tar.xz
Add <datadir>/settings.json persistent settings storage.
Persistent settings are used in followup PRs #15936 to unify gui settings between bitcoin-qt and bitcoind, and #15937 to add a load_on_startup flag to the loadwallet RPC and maintain a dynamic list of wallets that should be loaded on startup that also can be shared between bitcoind and bitcoin-qt.
Diffstat (limited to 'src/util/system.h')
-rw-r--r--src/util/system.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/util/system.h b/src/util/system.h
index a5eea5dfab..0bd14cc9ea 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -41,6 +41,7 @@
int64_t GetStartupTime();
extern const char * const BITCOIN_CONF_FILENAME;
+extern const char * const BITCOIN_SETTINGS_FILENAME;
void SetupEnvironment();
bool SetupNetworking();
@@ -334,6 +335,39 @@ public:
Optional<unsigned int> GetArgFlags(const std::string& name) const;
/**
+ * Read and update settings file with saved settings. This needs to be
+ * called after SelectParams() because the settings file location is
+ * network-specific.
+ */
+ bool InitSettings(std::string& error);
+
+ /**
+ * Get settings file path, or return false if read-write settings were
+ * disabled with -nosettings.
+ */
+ bool GetSettingsPath(fs::path* filepath = nullptr, bool temp = false) const;
+
+ /**
+ * Read settings file. Push errors to vector, or log them if null.
+ */
+ bool ReadSettingsFile(std::vector<std::string>* errors = nullptr);
+
+ /**
+ * Write settings file. Push errors to vector, or log them if null.
+ */
+ bool WriteSettingsFile(std::vector<std::string>* errors = nullptr) const;
+
+ /**
+ * Access settings with lock held.
+ */
+ template <typename Fn>
+ void LockSettings(Fn&& fn)
+ {
+ LOCK(cs_args);
+ fn(m_settings);
+ }
+
+ /**
* Log the config file options and the command line arguments,
* useful for troubleshooting.
*/