aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2024-01-09 10:25:08 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-01-22 10:50:03 -0300
commite9014042a6bed8c16cc9a31fc35cb709d4b3c766 (patch)
treea031e1bf1d456af105ef757ee5ff9318be5299a2 /src/common
parent966f5de99a9f5da05c91378ad1e8ea8ed37ac3b3 (diff)
downloadbitcoin-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.cpp11
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);
}