diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2024-01-09 10:25:08 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2024-01-22 10:50:03 -0300 |
commit | e9014042a6bed8c16cc9a31fc35cb709d4b3c766 (patch) | |
tree | a031e1bf1d456af105ef757ee5ff9318be5299a2 /src/common | |
parent | 966f5de99a9f5da05c91378ad1e8ea8ed37ac3b3 (diff) | |
download | bitcoin-e9014042a6bed8c16cc9a31fc35cb709d4b3c766.tar.xz |
settings: add auto-generated warning msg for editing the file manually
Hopefully, refraining users from modifying the file unless they are
certain about the potential consequences.
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/settings.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index cbf794a7c6..913ad6d76a 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -4,6 +4,10 @@ #include <common/settings.h> +#if defined(HAVE_CONFIG_H) +#include <config/bitcoin-config.h> +#endif + #include <tinyformat.h> #include <univalue.h> #include <util/fs.h> @@ -116,6 +120,13 @@ bool WriteSettings(const fs::path& path, std::vector<std::string>& errors) { SettingsValue out(SettingsValue::VOBJ); + // Add auto-generated warning comment only if it does not exist + if (!values.contains("_warning_")) { + out.pushKV("_warning_", strprintf("This file is automatically generated and updated by %s. Please do not edit this file while the node " + "is running, as any changes might be ignored or overwritten.", + PACKAGE_NAME)); + } + // Push settings values for (const auto& value : values) { out.pushKVEnd(value.first, value.second); } |