File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,8 @@ class Chain
356356 virtual common::SettingsValue getRwSetting (const std::string& name) = 0;
357357
358358 // ! Updates a setting in <datadir>/settings.json.
359+ // ! Null can be passed to erase the setting. There is intentionally no
360+ // ! support for writing null values to settings.json.
359361 // ! Depending on the action returned by the update function, this will either
360362 // ! update the setting in memory or write the updated settings to disk.
361363 virtual bool updateRwSetting (const std::string& name, const SettingsUpdate& update_function) = 0;
Original file line number Diff line number Diff line change @@ -819,10 +819,14 @@ class ChainImpl : public Chain
819819 {
820820 std::optional<interfaces::SettingsAction> action;
821821 args ().LockSettings ([&](common::Settings& settings) {
822- auto * ptr_value = common::FindKey (settings.rw_settings , name);
823- // Create value if it doesn't exist
824- auto & value = ptr_value ? *ptr_value : settings.rw_settings [name];
825- action = update_settings_func (value);
822+ if (auto * value = common::FindKey (settings.rw_settings , name)) {
823+ action = update_settings_func (*value);
824+ if (value->isNull ()) settings.rw_settings .erase (name);
825+ } else {
826+ UniValue new_value;
827+ action = update_settings_func (new_value);
828+ if (!new_value.isNull ()) settings.rw_settings [name] = std::move (new_value);
829+ }
826830 });
827831 if (!action) return false ;
828832 // Now dump value to disk if requested
You can’t perform that action at this time.
0 commit comments