diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-02-02 21:22:30 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-02-02 21:22:30 +0200 |
commit | ab2b3480b2c6bfb310e04f4d4775761554b32dd5 (patch) | |
tree | 60db324dd493dc059e79371a9f72321092bc2c3e /src | |
parent | Merge pull request #1636 (diff) | |
parent | Add change_password for simplewallet (diff) | |
download | monero-ab2b3480b2c6bfb310e04f4d4775761554b32dd5.tar.xz |
Merge pull request #1639
48aa9cf0 Add change_password for simplewallet (Ashley Perpetual)
Diffstat (limited to 'src')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 27 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index c7487cae8..8fc2559bd 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(); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 237c1e3e1..9918300df 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -162,6 +162,7 @@ namespace cryptonote bool export_outputs(const std::vector<std::string> &args); bool import_outputs(const std::vector<std::string> &args); bool show_transfer(const std::vector<std::string> &args); + bool change_password(const std::vector<std::string>& args); uint64_t get_daemon_blockchain_height(std::string& err); bool try_connect_to_daemon(bool silent = false, uint32_t* version = nullptr); |