MCPcopy Create free account
hub / github.com/ElementsProject/elements / loadwallet

Function loadwallet

src/wallet/rpc/wallet.cpp:194–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194static RPCHelpMan loadwallet()
195{
196 return RPCHelpMan{"loadwallet",
197 "\nLoads a wallet from a wallet file or directory."
198 "\nNote that all wallet command-line options used when starting elementsd will be"
199 "\napplied to the new wallet.\n",
200 {
201 {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet directory or .dat file."},
202 {"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
203 },
204 RPCResult{
205 RPCResult::Type::OBJ, "", "",
206 {
207 {RPCResult::Type::STR, "name", "The wallet name if loaded successfully."},
208 {RPCResult::Type::STR, "warning", "Warning message if wallet was not loaded cleanly."},
209 }
210 },
211 RPCExamples{
212 HelpExampleCli("loadwallet", "\"test.dat\"")
213 + HelpExampleRpc("loadwallet", "\"test.dat\"")
214 },
215 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
216{
217 WalletContext& context = EnsureWalletContext(request.context);
218 const std::string name(request.params[0].get_str());
219
220 DatabaseOptions options;
221 DatabaseStatus status;
222 options.require_existing = true;
223 bilingual_str error;
224 std::vector<bilingual_str> warnings;
225 std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
226 std::shared_ptr<CWallet> const wallet = LoadWallet(context, name, load_on_start, options, status, error, warnings);
227
228 HandleWalletError(wallet, status, error);
229
230 UniValue obj(UniValue::VOBJ);
231 obj.pushKV("name", wallet->GetName());
232 obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
233
234 return obj;
235},
236 };
237}
238
239static RPCHelpMan setwalletflag()
240{

Callers

nothing calls this directly

Calls 10

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
LoadWalletFunction · 0.85
HandleWalletErrorFunction · 0.85
JoinFunction · 0.85
UntranslatedFunction · 0.85
get_boolMethod · 0.80
isNullMethod · 0.45
pushKVMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected