simplewallet: always gracefully exit on EOF
This commit is contained in:
parent
2b57845766
commit
ead6956080
1 changed files with 34 additions and 0 deletions
|
@ -257,6 +257,8 @@ bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<st
|
|||
if (m_wallet->get_seed_language().empty())
|
||||
{
|
||||
std::string mnemonic_language = get_mnemonic_language();
|
||||
if (mnemonic_language.empty())
|
||||
return true;
|
||||
m_wallet->set_seed_language(mnemonic_language);
|
||||
}
|
||||
|
||||
|
@ -304,6 +306,8 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s
|
|||
}
|
||||
|
||||
std::string mnemonic_language = get_mnemonic_language();
|
||||
if (mnemonic_language.empty())
|
||||
return true;
|
||||
m_wallet->set_seed_language(mnemonic_language);
|
||||
m_wallet->rewrite(m_wallet_file, pwd_container.password());
|
||||
return true;
|
||||
|
@ -698,6 +702,10 @@ bool simple_wallet::ask_wallet_create_if_needed()
|
|||
tr("Specify wallet file name (e.g., MyWallet). If the wallet doesn't exist, it will be created.\n"
|
||||
"Wallet file name: ")
|
||||
);
|
||||
if (std::cin.eof())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
valid_path = tools::wallet2::wallet_valid_path_format(wallet_path);
|
||||
if (!valid_path)
|
||||
{
|
||||
|
@ -1020,6 +1028,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
if (m_electrum_seed.empty())
|
||||
{
|
||||
m_electrum_seed = command_line::input_line("Specify Electrum seed: ");
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (m_electrum_seed.empty())
|
||||
{
|
||||
fail_msg_writer() << tr("specify a recovery parameter with the --electrum-seed=\"words list here\"");
|
||||
|
@ -1037,6 +1047,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
{
|
||||
// parse address
|
||||
std::string address_string = command_line::input_line("Standard address: ");
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (address_string.empty()) {
|
||||
fail_msg_writer() << tr("No data supplied, cancelled");
|
||||
return false;
|
||||
|
@ -1052,6 +1064,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
|
||||
// parse view secret key
|
||||
std::string viewkey_string = command_line::input_line("View key: ");
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (viewkey_string.empty()) {
|
||||
fail_msg_writer() << tr("No data supplied, cancelled");
|
||||
return false;
|
||||
|
@ -1084,6 +1098,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
{
|
||||
// parse address
|
||||
std::string address_string = command_line::input_line("Standard address: ");
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (address_string.empty()) {
|
||||
fail_msg_writer() << tr("No data supplied, cancelled");
|
||||
return false;
|
||||
|
@ -1099,6 +1115,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
|
||||
// parse spend secret key
|
||||
std::string spendkey_string = command_line::input_line("Spend key: ");
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (spendkey_string.empty()) {
|
||||
fail_msg_writer() << tr("No data supplied, cancelled");
|
||||
return false;
|
||||
|
@ -1113,6 +1131,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
|
||||
// parse view secret key
|
||||
std::string viewkey_string = command_line::input_line("View key: ");
|
||||
if (std::cin.eof())
|
||||
return false;
|
||||
if (viewkey_string.empty()) {
|
||||
fail_msg_writer() << tr("No data supplied, cancelled");
|
||||
return false;
|
||||
|
@ -1232,6 +1252,8 @@ std::string simple_wallet::get_mnemonic_language()
|
|||
while (language_number < 0)
|
||||
{
|
||||
language_choice = command_line::input_line(tr("Enter the number corresponding to the language of your choice: "));
|
||||
if (std::cin.eof())
|
||||
return std::string();
|
||||
try
|
||||
{
|
||||
language_number = std::stoi(language_choice);
|
||||
|
@ -1270,6 +1292,8 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
|||
"a deprecated version of the wallet. Please use the new seed that we provide.\n");
|
||||
}
|
||||
mnemonic_language = get_mnemonic_language();
|
||||
if (mnemonic_language.empty())
|
||||
return false;
|
||||
}
|
||||
|
||||
m_wallet_file = wallet_file;
|
||||
|
@ -1397,6 +1421,8 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa
|
|||
message_writer(epee::log_space::console_color_green, false) << "\n" << tr("You had been using "
|
||||
"a deprecated version of the wallet. Please proceed to upgrade your wallet.\n");
|
||||
std::string mnemonic_language = get_mnemonic_language();
|
||||
if (mnemonic_language.empty())
|
||||
return false;
|
||||
m_wallet->set_seed_language(mnemonic_language);
|
||||
m_wallet->rewrite(m_wallet_file, password);
|
||||
|
||||
|
@ -2013,6 +2039,10 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str
|
|||
|
||||
// prompt the user for confirmation given the dns query and dnssec status
|
||||
std::string confirm_dns_ok = command_line::input_line(prompt.str());
|
||||
if (std::cin.eof())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (confirm_dns_ok != "Y" && confirm_dns_ok != "y" && confirm_dns_ok != "Yes" && confirm_dns_ok != "yes"
|
||||
&& confirm_dns_ok != tr("yes") && confirm_dns_ok != tr("no"))
|
||||
{
|
||||
|
@ -2097,6 +2127,8 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str
|
|||
print_money(total_fee)).str();
|
||||
}
|
||||
std::string accepted = command_line::input_line(prompt_str);
|
||||
if (std::cin.eof())
|
||||
return true;
|
||||
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
|
||||
{
|
||||
fail_msg_writer() << tr("transaction cancelled.");
|
||||
|
@ -2254,6 +2286,8 @@ bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
|
|||
print_money(total_fee)).str();
|
||||
}
|
||||
std::string accepted = command_line::input_line(prompt_str);
|
||||
if (std::cin.eof())
|
||||
return true;
|
||||
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
|
||||
{
|
||||
fail_msg_writer() << tr("transaction cancelled.");
|
||||
|
|
Loading…
Reference in a new issue