Better fix (#4)

This commit is contained in:
hyc 2016-08-10 00:54:20 +01:00 committed by luigi1111
parent d2644c15c3
commit 709c7247cd
2 changed files with 9 additions and 4 deletions

View file

@ -851,7 +851,7 @@ bool simple_wallet::ask_wallet_create_if_needed()
// add logic to error out if new wallet requested but named wallet file exists // add logic to error out if new wallet requested but named wallet file exists
if (keys_file_exists || wallet_file_exists) if (keys_file_exists || wallet_file_exists)
{ {
if (!m_generate_new.empty() || m_restore_deterministic_wallet || !m_generate_from_view_key.empty() || !m_generate_from_keys.empty() || !m_generate_from_json.empty()) if (!m_generate_new.empty() || m_restoring)
{ {
fail_msg_writer() << tr("attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting."); fail_msg_writer() << tr("attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting.");
return false; return false;
@ -1227,7 +1227,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
if (!get_password(vm, true, pwd_container)) if (!get_password(vm, true, pwd_container))
return false; return false;
if (!m_generate_new.empty() || m_restore_deterministic_wallet || !m_generate_from_view_key.empty() || !m_generate_from_keys.empty() || !m_generate_from_json.empty()) if (!m_generate_new.empty() || m_restoring)
{ {
if (m_wallet_file.empty()) m_wallet_file = m_generate_new; // alias for simplicity later if (m_wallet_file.empty()) m_wallet_file = m_generate_new; // alias for simplicity later
@ -1259,7 +1259,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
return false; return false;
} }
} }
if (!m_restore_height && (m_generate_new.empty() || m_restore_deterministic_wallet)) if (!m_restore_height && m_restoring)
{ {
std::string heightstr = command_line::input_line("Restore from specific blockchain height (optional, default 0): "); std::string heightstr = command_line::input_line("Restore from specific blockchain height (optional, default 0): ");
if (std::cin.eof()) if (std::cin.eof())
@ -1447,6 +1447,10 @@ bool simple_wallet::handle_command_line(const boost::program_options::variables_
m_trusted_daemon = command_line::get_arg(vm, arg_trusted_daemon); m_trusted_daemon = command_line::get_arg(vm, arg_trusted_daemon);
m_allow_mismatched_daemon_version = command_line::get_arg(vm, arg_allow_mismatched_daemon_version); m_allow_mismatched_daemon_version = command_line::get_arg(vm, arg_allow_mismatched_daemon_version);
m_restore_height = command_line::get_arg(vm, arg_restore_height); m_restore_height = command_line::get_arg(vm, arg_restore_height);
m_restoring = !m_generate_from_view_key.empty() ||
!m_generate_from_keys.empty() ||
!m_generate_from_json.empty() ||
m_restore_deterministic_wallet;
return true; return true;
} }
@ -1546,7 +1550,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
m_wallet->set_seed_language(mnemonic_language); m_wallet->set_seed_language(mnemonic_language);
// for a totally new account, we don't care about older blocks. // for a totally new account, we don't care about older blocks.
if (!m_generate_new.empty() && !m_restore_deterministic_wallet) if (!m_restoring)
{ {
std::string err; std::string err;
m_wallet->set_refresh_from_block_height(get_daemon_blockchain_height(err)); m_wallet->set_refresh_from_block_height(get_daemon_blockchain_height(err));

View file

@ -243,6 +243,7 @@ namespace cryptonote
bool m_non_deterministic; // old 2-random generation bool m_non_deterministic; // old 2-random generation
bool m_trusted_daemon; bool m_trusted_daemon;
bool m_allow_mismatched_daemon_version; bool m_allow_mismatched_daemon_version;
bool m_restoring; // are we restoring, by whatever method?
uint64_t m_restore_height; // optional uint64_t m_restore_height; // optional
std::string m_daemon_address; std::string m_daemon_address;