mirror of
https://github.com/wownero/wownero.git
synced 2026-12-03 06:24:11 +01:00
simplewallet: allow closing wallet when locked due to inactivity
This commit is contained in:
@@ -4618,14 +4618,18 @@ std::string simple_wallet::get_mnemonic_language()
|
|||||||
return language_list_self[language_number];
|
return language_list_self[language_number];
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
boost::optional<tools::password_container> simple_wallet::get_and_verify_password() const
|
boost::optional<tools::password_container> simple_wallet::get_and_verify_password(bool *read_failed) const
|
||||||
{
|
{
|
||||||
|
if (read_failed) *read_failed = false;
|
||||||
const bool verify = m_wallet_file.empty();
|
const bool verify = m_wallet_file.empty();
|
||||||
auto pwd_container = (m_wallet->is_background_wallet() && m_wallet->background_sync_type() == tools::wallet2::BackgroundSyncCustomPassword)
|
auto pwd_container = (m_wallet->is_background_wallet() && m_wallet->background_sync_type() == tools::wallet2::BackgroundSyncCustomPassword)
|
||||||
? background_sync_cache_password_prompter(verify)
|
? background_sync_cache_password_prompter(verify)
|
||||||
: default_password_prompter(verify);
|
: default_password_prompter(verify);
|
||||||
if (!pwd_container)
|
if (!pwd_container)
|
||||||
|
{
|
||||||
|
if (read_failed) *read_failed = true;
|
||||||
return boost::none;
|
return boost::none;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_wallet->verify_password(pwd_container->password()))
|
if (!m_wallet->verify_password(pwd_container->password()))
|
||||||
{
|
{
|
||||||
@@ -6208,6 +6212,7 @@ bool simple_wallet::prompt_if_old(const std::vector<tools::wallet2::pending_tx>
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
void simple_wallet::check_for_inactivity_lock(bool user)
|
void simple_wallet::check_for_inactivity_lock(bool user)
|
||||||
{
|
{
|
||||||
|
bool close_wallet = false;
|
||||||
if (m_locked)
|
if (m_locked)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_READLINE
|
#ifdef HAVE_READLINE
|
||||||
@@ -6269,7 +6274,8 @@ void simple_wallet::check_for_inactivity_lock(bool user)
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto pwd_container = get_and_verify_password();
|
bool read_failed = false;
|
||||||
|
const auto pwd_container = get_and_verify_password(&read_failed);
|
||||||
if (pwd_container)
|
if (pwd_container)
|
||||||
{
|
{
|
||||||
if (started_background_sync)
|
if (started_background_sync)
|
||||||
@@ -6279,6 +6285,12 @@ void simple_wallet::check_for_inactivity_lock(bool user)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (read_failed)
|
||||||
|
{
|
||||||
|
// Password read was interrupted; close the wallet instead of looping back to the prompt
|
||||||
|
close_wallet = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
@@ -6297,6 +6309,7 @@ void simple_wallet::check_for_inactivity_lock(bool user)
|
|||||||
m_in_command = false;
|
m_in_command = false;
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
}
|
}
|
||||||
|
if (close_wallet) stop();
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool simple_wallet::on_command(bool (simple_wallet::*cmd)(const std::vector<std::string>&), const std::vector<std::string> &args)
|
bool simple_wallet::on_command(bool (simple_wallet::*cmd)(const std::vector<std::string>&), const std::vector<std::string> &args)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace cryptonote
|
|||||||
void wallet_idle_thread();
|
void wallet_idle_thread();
|
||||||
|
|
||||||
//! \return Prompts user for password and verifies against local file. Logs on error and returns `none`
|
//! \return Prompts user for password and verifies against local file. Logs on error and returns `none`
|
||||||
boost::optional<tools::password_container> get_and_verify_password() const;
|
boost::optional<tools::password_container> get_and_verify_password(bool *read_failed = nullptr) const;
|
||||||
|
|
||||||
boost::optional<epee::wipeable_string> new_wallet(const boost::program_options::variables_map& vm, const crypto::secret_key& recovery_key,
|
boost::optional<epee::wipeable_string> new_wallet(const boost::program_options::variables_map& vm, const crypto::secret_key& recovery_key,
|
||||||
bool recover, bool two_random, const std::string &old_language);
|
bool recover, bool two_random, const std::string &old_language);
|
||||||
|
|||||||
Reference in New Issue
Block a user