aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 462cdf58f..faeed31ce 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -212,17 +212,17 @@ namespace
return message_writer(epee::log_space::console_color_red, true, sw::tr("Error: "), LOG_LEVEL_0);
}
- bool is_it_true(std::string s)
+ bool is_it_true(const std::string& s)
{
- std::transform(s.begin(), s.end(), s.begin(), ::tolower);
- if (s == "true")
+ if (s == "1" || command_line::is_yes(s))
return true;
- if (s == "1")
- return true;
- if (s == "y" || s == "yes")
+
+ boost::algorithm::is_iequal ignore_case{};
+ if (boost::algorithm::equals("true", s, ignore_case))
return true;
- if (s == sw::tr("yes"))
+ if (boost::algorithm::equals(simple_wallet::tr("true"), s, ignore_case))
return true;
+
return false;
}
@@ -263,6 +263,10 @@ namespace
return "invalid";
}
+ std::string get_version_string(uint32_t version)
+ {
+ return boost::lexical_cast<std::string>(version >> 16) + "." + boost::lexical_cast<std::string>(version & 0xffff);
+ }
}
@@ -916,7 +920,7 @@ bool simple_wallet::ask_wallet_create_if_needed()
LOG_ERROR("Unexpected std::cin.eof() - Exited simple_wallet::ask_wallet_create_if_needed()");
return false;
}
- if(is_it_true(confirm_creation))
+ if(command_line::is_yes(confirm_creation))
{
success_msg_writer() << tr("Generating new wallet...");
m_generate_new = wallet_path;
@@ -1189,8 +1193,8 @@ bool simple_wallet::handle_command_line(const boost::program_options::variables_
//----------------------------------------------------------------------------------------------------
bool simple_wallet::try_connect_to_daemon(bool silent)
{
- bool same_version = false;
- if (!m_wallet->check_connection(&same_version))
+ uint32_t version = 0;
+ if (!m_wallet->check_connection(&version))
{
if (!silent)
fail_msg_writer() << tr("wallet failed to connect to daemon: ") << m_wallet->get_daemon_address() << ". " <<
@@ -1198,11 +1202,10 @@ bool simple_wallet::try_connect_to_daemon(bool silent)
"Please make sure daemon is running or restart the wallet with the correct daemon address.");
return false;
}
- if (!m_allow_mismatched_daemon_version && !same_version)
+ if (!m_allow_mismatched_daemon_version && ((version >> 16) != CORE_RPC_VERSION_MAJOR))
{
if (!silent)
- fail_msg_writer() << tr("Daemon uses a different RPC version that the wallet: ") << m_wallet->get_daemon_address() << ". " <<
- tr("Either update one of them, or use --allow-mismatched-daemon-version.");
+ fail_msg_writer() << boost::format(tr("Daemon uses a different RPC major version (%u) than the wallet (%u): %s. Either update one of them, or use --allow-mismatched-daemon-version.")) % (version>>16) % CORE_RPC_VERSION_MAJOR % m_wallet->get_daemon_address();
return false;
}
return true;
@@ -1977,8 +1980,7 @@ bool simple_wallet::get_address_from_str(const std::string &str, cryptonote::acc
{
return false;
}
- 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"))
+ if (!command_line::is_yes(confirm_dns_ok))
{
fail_msg_writer() << tr("you have cancelled the transfer request");
return false;
@@ -2136,7 +2138,7 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
std::string accepted = command_line::input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No)"));
if (std::cin.eof())
return true;
- if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
+ if (!command_line::is_yes(accepted))
{
fail_msg_writer() << tr("transaction cancelled.");
@@ -2220,7 +2222,7 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
std::string accepted = command_line::input_line(prompt.str());
if (std::cin.eof())
return true;
- if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
+ if (!command_line::is_yes(accepted))
{
fail_msg_writer() << tr("transaction cancelled.");
@@ -2399,7 +2401,7 @@ bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
std::string accepted = command_line::input_line(prompt_str);
if (std::cin.eof())
return true;
- if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
+ if (!command_line::is_yes(accepted))
{
fail_msg_writer() << tr("transaction cancelled.");
@@ -2613,7 +2615,7 @@ bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
std::string accepted = command_line::input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No)"));
if (std::cin.eof())
return true;
- if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
+ if (!command_line::is_yes(accepted))
{
fail_msg_writer() << tr("transaction cancelled.");
@@ -2658,7 +2660,7 @@ bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
std::string accepted = command_line::input_line(prompt_str);
if (std::cin.eof())
return true;
- if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
+ if (!command_line::is_yes(accepted))
{
fail_msg_writer() << tr("transaction cancelled.");
@@ -2853,8 +2855,7 @@ bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes,
uint64_t fee = amount - amount_to_dests;
std::string prompt_str = (boost::format(tr("Loaded %lu transactions, for %s, fee %s, %s, %s, with min mixin %lu. %sIs this okay? (Y/Yes/N/No)")) % (unsigned long)get_num_txes() % print_money(amount) % print_money(fee) % dest_string % change_string % (unsigned long)min_mixin % extra_message).str();
- std::string accepted = command_line::input_line(prompt_str);
- return is_it_true(accepted);
+ return command_line::is_yes(command_line::input_line(prompt_str));
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs)
@@ -3564,7 +3565,8 @@ bool simple_wallet::get_tx_note(const std::vector<std::string> &args)
bool simple_wallet::status(const std::vector<std::string> &args)
{
uint64_t local_height = m_wallet->get_blockchain_current_height();
- if (!try_connect_to_daemon())
+ uint32_t version = 0;
+ if (!m_wallet->check_connection(&version))
{
success_msg_writer() << "Refreshed " << local_height << "/?, no daemon connected";
return true;
@@ -3575,7 +3577,8 @@ bool simple_wallet::status(const std::vector<std::string> &args)
if (err.empty())
{
bool synced = local_height == bc_height;
- success_msg_writer() << "Refreshed " << local_height << "/" << bc_height << ", " << (synced ? "synced" : "syncing");
+ success_msg_writer() << "Refreshed " << local_height << "/" << bc_height << ", " << (synced ? "synced" : "syncing")
+ << ", daemon RPC v" << get_version_string(version);
}
else
{