aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authorAshley Perpetual <ashleyperpetual@gmail.com>2017-01-27 15:12:18 +0800
committerAshley Perpetual <ashleyperpetual@gmail.com>2017-01-29 03:04:17 +0800
commit48aa9cf0357ea0ec72d9399d41cccb7d889e24e1 (patch)
tree2bd6d48d47666d0714dbc823944abbcc68ccab41 /src/simplewallet/simplewallet.cpp
parentMerge pull request #1618 (diff)
downloadmonero-48aa9cf0357ea0ec72d9399d41cccb7d889e24e1.tar.xz
Add change_password for simplewallet
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 50509040c..0b465cafd 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -362,6 +362,33 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s
return true;
}
+bool simple_wallet::change_password(const std::vector<std::string> &args)
+{
+ const auto orig_pwd_container = get_and_verify_password();
+
+ if(orig_pwd_container == boost::none)
+ {
+ fail_msg_writer() << tr("Your original password was incorrect.");
+ return false;
+ }
+
+ // prompts for a new password, this is not a new wallet so pass in false.
+ const auto pwd_container = tools::wallet2::password_prompt(false);
+
+ try
+ {
+ m_wallet->rewrite(m_wallet_file, pwd_container->password());
+ m_wallet->store();
+ }
+ catch (const wallet_logic_error& e)
+ {
+ fail_msg_writer() << tr("Error with wallet rewrite: ") << e.what();
+ return false;
+ }
+
+ return true;
+}
+
bool simple_wallet::set_always_confirm_transfers(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
const auto pwd_container = get_and_verify_password();