mirror of
https://github.com/monero-project/monero.git
synced 2024-12-27 14:19:25 -05:00
simplewallet: allow a different password for the watch-only wallet
This commit is contained in:
parent
c882af63c1
commit
fb2007181e
@ -81,14 +81,15 @@ namespace tools
|
|||||||
m_empty = true;
|
m_empty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool password_container::read_password()
|
bool password_container::read_password(const char *message)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
bool r;
|
bool r;
|
||||||
if (is_cin_tty())
|
if (is_cin_tty())
|
||||||
{
|
{
|
||||||
std::cout << "password: ";
|
if (message)
|
||||||
|
std::cout << message << ": ";
|
||||||
r = read_from_tty();
|
r = read_from_tty();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -48,7 +48,7 @@ namespace tools
|
|||||||
bool empty() const { return m_empty; }
|
bool empty() const { return m_empty; }
|
||||||
const std::string& password() const { return m_password; }
|
const std::string& password() const { return m_password; }
|
||||||
void password(std::string&& val) { m_password = std::move(val); m_empty = false; }
|
void password(std::string&& val) { m_password = std::move(val); m_empty = false; }
|
||||||
bool read_password();
|
bool read_password(const char *message = "password");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool read_from_file();
|
bool read_from_file();
|
||||||
|
@ -767,18 +767,23 @@ bool simple_wallet::save_watch_only(const std::vector<std::string> &args/* = std
|
|||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
tools::password_container pwd_container;
|
tools::password_container pwd_container;
|
||||||
success = pwd_container.read_password();
|
|
||||||
|
success = pwd_container.read_password("Password for the new watch-only wallet");
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
fail_msg_writer() << "failed to read wallet password";
|
fail_msg_writer() << "failed to read wallet password";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
std::string password = pwd_container.password();
|
||||||
/* verify password before using so user doesn't accidentally set a new password for rewritten wallet */
|
success = pwd_container.read_password("Enter new password again");
|
||||||
success = m_wallet->verify_password(pwd_container.password());
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
fail_msg_writer() << "invalid password";
|
fail_msg_writer() << "failed to read wallet password";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (password != pwd_container.password())
|
||||||
|
{
|
||||||
|
fail_msg_writer() << "passwords do not match";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user