diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 48045206e42ff2..294ed0c553c98d 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -819,10 +819,14 @@ class ChainImpl : public Chain { std::optional action; args().LockSettings([&](common::Settings& settings) { - auto* ptr_value = common::FindKey(settings.rw_settings, name); - // Create value if it doesn't exist - auto& value = ptr_value ? *ptr_value : settings.rw_settings[name]; - action = update_settings_func(value); + if (auto* value = common::FindKey(settings.rw_settings, name)) { + action = update_settings_func(*value); + if (value->isNull()) settings.rw_settings.erase(name); + } else { + UniValue new_value; + action = update_settings_func(new_value); + if (!new_value.isNull()) settings.rw_settings[name] = std::move(new_value); + } }); if (!action) return false; // Now dump value to disk if requested @@ -830,7 +834,7 @@ class ChainImpl : public Chain } bool overwriteRwSetting(const std::string& name, common::SettingsValue value, interfaces::SettingsAction action) override { - if (value.isNull()) return deleteRwSettings(name, action); + if (value.isNull()) return false; // disallow overwriting with null values. return updateRwSetting(name, [&](common::SettingsValue& settings) { settings = std::move(value); return action;