From d4e979cd2bc8b530296fe4b78554254f8f266fb3 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 10 Jun 2019 21:32:56 +0300 Subject: [PATCH] simplewallet: request password from CLI if running in RPC mode with no password specified (ZANO-364) --- src/simplewallet/simplewallet.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index e9ad2169..0a24844a 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1534,14 +1534,22 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - if (!command_line::has_arg(vm, arg_password) ) + tools::password_container pwd_container; + if (command_line::has_arg(vm, arg_password)) { - LOG_ERROR("Wallet password is not set."); - return EXIT_FAILURE; + pwd_container.password(command_line::get_arg(vm, arg_password)); + } + else + { + bool r = pwd_container.read_password(); + if (!r) + { + LOG_ERROR("failed to read wallet password"); + return EXIT_FAILURE; + } } std::string wallet_file = command_line::get_arg(vm, arg_wallet_file); - std::string wallet_password = command_line::get_arg(vm, arg_password); std::string daemon_address = command_line::get_arg(vm, arg_daemon_address); std::string daemon_host = command_line::get_arg(vm, arg_daemon_host); int daemon_port = command_line::get_arg(vm, arg_daemon_port); @@ -1559,7 +1567,7 @@ int main(int argc, char* argv[]) try { LOG_PRINT_L0("Loading wallet..."); - wal.load(epee::string_encoding::convert_to_unicode(wallet_file), wallet_password); + wal.load(epee::string_encoding::convert_to_unicode(wallet_file), pwd_container.password()); } catch (const tools::error::wallet_load_notice_wallet_restored& e) { @@ -1621,7 +1629,8 @@ int main(int argc, char* argv[]) LOG_ERROR("Failed to store wallet: " << e.what()); return EXIT_FAILURE; } - }else + } + else // if(command_line::has_arg(vm, tools::wallet_rpc_server::arg_rpc_bind_port)) { //runs wallet with console interface sw->set_offline_mode(offline_mode);