4300 {
4301 std::unique_ptr<tools::wallet2> wal;
4302 try
4303 {
4306 if (testnet && stagenet)
4307 {
4309 return false;
4310 }
4311
4314
4319 const auto password_prompt = prompt_for_password ? password_prompter : nullptr;
4320
4321 if(!wallet_file.empty() && !from_json.empty())
4322 {
4324 return false;
4325 }
4326
4327 if (!wallet_dir.empty())
4328 {
4329 wal = NULL;
4330 goto just_dir;
4331 }
4332
4333 if (wallet_file.empty() && from_json.empty())
4334 {
4336 return false;
4337 }
4338
4340 if(!wallet_file.empty())
4341 {
4343 }
4344 else
4345 {
4346 try
4347 {
4349 wal = std::move(rc.first);
4350 }
4351 catch (const std::exception &e)
4352 {
4353 MERROR(
"Error creating wallet: " << e.what());
4354 return false;
4355 }
4356 }
4357 if (!wal)
4358 {
4359 return false;
4360 }
4361
4362 bool quit = false;
4364 assert(wal);
4365 quit = true;
4366 wal->stop();
4367 });
4368
4369 wal->refresh(wal->is_trusted_daemon());
4370
4371 if (quit)
4372 {
4374 wal->store();
4376 return false;
4377 }
4379 }
4380 catch (const std::exception& e)
4381 {
4383 return false;
4384 }
4385 just_dir:
4386 if (wal) wrpc->set_wallet(wal.release());
4387 bool r = wrpc->init(&vm);
4390 wrpc->send_stop_signal();
4391 });
4393 try
4394 {
4395 wrpc->run();
4396 }
4397 catch (const std::exception &e)
4398 {
4400 return false;
4401 }
4403 try
4404 {
4406 wrpc->stop();
4408 }
4409 catch (const std::exception& e)
4410 {
4412 return false;
4413 }
4414 return true;
4415 }
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
command_line::arg_descriptor< std::string > arg_generate_from_json()
command_line::arg_descriptor< std::string > arg_wallet_file()