diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-12-05 15:57:12 -0500 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2021-06-10 09:58:45 -0500 |
commit | 49ee2a0ad88e0e656234b769d806987784ff1e28 (patch) | |
tree | 06c2db387a170d332bdb969980b4dee2293990d4 /src/wallet/load.cpp | |
parent | 1704bbf2263f16c720604cfab4ccb775315df690 (diff) |
Avoid wallet code writing node settings file
Change wallet loading code to access settings through the Chain
interface instead of writing settings.json directly.
Diffstat (limited to 'src/wallet/load.cpp')
-rw-r--r-- | src/wallet/load.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index dbf9fd46b6..5b3fccd54b 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -50,18 +50,20 @@ bool VerifyWallets(interfaces::Chain& chain) options.require_existing = true; options.verify = false; if (MakeWalletDatabase("", options, status, error_string)) { - gArgs.LockSettings([&](util::Settings& settings) { - util::SettingsValue wallets(util::SettingsValue::VARR); - wallets.push_back(""); // Default wallet name is "" - settings.rw_settings["wallet"] = wallets; - }); + util::SettingsValue wallets(util::SettingsValue::VARR); + wallets.push_back(""); // Default wallet name is "" + // Pass write=false because no need to write file and probably + // better not to. If unnamed wallet needs to be added next startup + // and the setting is empty, this code will just run again. + chain.updateRwSetting("wallet", wallets, /* write= */ false); } } // Keep track of each wallet absolute path to detect duplicates. std::set<fs::path> wallet_paths; - for (const auto& wallet_file : gArgs.GetArgs("-wallet")) { + for (const auto& wallet : chain.getSettingsList("wallet")) { + const auto& wallet_file = wallet.get_str(); const fs::path path = fsbridge::AbsPathJoin(GetWalletDir(), wallet_file); if (!wallet_paths.insert(path).second) { @@ -91,7 +93,8 @@ bool LoadWallets(interfaces::Chain& chain) { try { std::set<fs::path> wallet_paths; - for (const std::string& name : gArgs.GetArgs("-wallet")) { + for (const auto& wallet : chain.getSettingsList("wallet")) { + const auto& name = wallet.get_str(); if (!wallet_paths.insert(name).second) { continue; } |