mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
chain: ensure updateRwSetting doesn't update to a null settings
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
parent
c8e2eeeffb
commit
df601993f2
2 changed files with 10 additions and 4 deletions
|
|
@ -819,10 +819,14 @@ public:
|
|||
{
|
||||
std::optional<interfaces::SettingsAction> 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue