| 116 | } |
| 117 | |
| 118 | bool LoadWallets(WalletContext& context) |
| 119 | { |
| 120 | interfaces::Chain& chain = *context.chain; |
| 121 | try { |
| 122 | std::set<fs::path> wallet_paths; |
| 123 | for (const auto& wallet : chain.getSettingsList("wallet")) { |
| 124 | if (!wallet.isStr()) { |
| 125 | chain.initError(_("Invalid value detected for '-wallet' or '-nowallet'. " |
| 126 | "'-wallet' requires a string value, while '-nowallet' accepts only '1' to disable all wallets")); |
| 127 | return false; |
| 128 | } |
| 129 | const auto& name = wallet.get_str(); |
| 130 | if (!wallet_paths.insert(fs::PathFromString(name)).second) { |
| 131 | continue; |
| 132 | } |
| 133 | DatabaseOptions options; |
| 134 | DatabaseStatus status; |
| 135 | ReadDatabaseArgs(*context.args, options); |
| 136 | options.require_existing = true; |
| 137 | options.verify = false; // No need to verify, assuming verified earlier in VerifyWallets() |
| 138 | bilingual_str error; |
| 139 | std::vector<bilingual_str> warnings; |
| 140 | std::unique_ptr<WalletDatabase> database = MakeWalletDatabase(name, options, status, error); |
| 141 | if (!database) { |
| 142 | if (status == DatabaseStatus::FAILED_NOT_FOUND) continue; |
| 143 | if (status == DatabaseStatus::FAILED_LEGACY_DISABLED) { |
| 144 | // Inform user that legacy wallet is not loaded and suggest upgrade options |
| 145 | chain.initWarning(error); |
| 146 | continue; |
| 147 | } |
| 148 | } |
| 149 | chain.initMessage(_("Loading wallet…")); |
| 150 | std::shared_ptr<CWallet> pwallet = database ? CWallet::LoadExisting(context, name, std::move(database), error, warnings) : nullptr; |
| 151 | if (!warnings.empty()) chain.initWarning(Join(warnings, Untranslated("\n"))); |
| 152 | if (!pwallet) { |
| 153 | chain.initError(error); |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | NotifyWalletLoaded(context, pwallet); |
| 158 | AddWallet(context, pwallet); |
| 159 | } |
| 160 | return true; |
| 161 | } catch (const std::runtime_error& e) { |
| 162 | chain.initError(Untranslated(e.what())); |
| 163 | return false; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void StartWallets(WalletContext& context) |
| 168 | { |
no test coverage detected