diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-06-12 16:45:29 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-06-12 16:45:29 +0100 |
commit | fb2007181ed453ee54369d02b98856e4dcf3045d (patch) | |
tree | c853db39bae3e019e096157fc9e790cce69586ab /src/simplewallet | |
parent | wallet: add watch only wallet support (diff) | |
download | monero-fb2007181ed453ee54369d02b98856e4dcf3045d.tar.xz |
simplewallet: allow a different password for the watch-only wallet
Diffstat (limited to 'src/simplewallet')
-rw-r--r-- | src/simplewallet/password_container.cpp | 5 | ||||
-rw-r--r-- | src/simplewallet/password_container.h | 2 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 15 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/simplewallet/password_container.cpp b/src/simplewallet/password_container.cpp index e5fb933bb..c1a570a3a 100644 --- a/src/simplewallet/password_container.cpp +++ b/src/simplewallet/password_container.cpp @@ -81,14 +81,15 @@ namespace tools m_empty = true; } - bool password_container::read_password() + bool password_container::read_password(const char *message) { clear(); bool r; if (is_cin_tty()) { - std::cout << "password: "; + if (message) + std::cout << message << ": "; r = read_from_tty(); } else diff --git a/src/simplewallet/password_container.h b/src/simplewallet/password_container.h index 8a4191c7a..56dd44cfa 100644 --- a/src/simplewallet/password_container.h +++ b/src/simplewallet/password_container.h @@ -48,7 +48,7 @@ namespace tools bool empty() const { return m_empty; } const std::string& password() const { return m_password; } void password(std::string&& val) { m_password = std::move(val); m_empty = false; } - bool read_password(); + bool read_password(const char *message = "password"); private: bool read_from_file(); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 3159e85d4..081d4c1b8 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -767,18 +767,23 @@ bool simple_wallet::save_watch_only(const std::vector<std::string> &args/* = std { bool success = false; tools::password_container pwd_container; - success = pwd_container.read_password(); + + success = pwd_container.read_password("Password for the new watch-only wallet"); if (!success) { fail_msg_writer() << "failed to read wallet password"; return true; } - - /* verify password before using so user doesn't accidentally set a new password for rewritten wallet */ - success = m_wallet->verify_password(pwd_container.password()); + std::string password = pwd_container.password(); + success = pwd_container.read_password("Enter new password again"); 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; } |