diff options
author | Oran Juice <oranjuices@hotmail.com> | 2014-10-19 01:00:18 +0530 |
---|---|---|
committer | Oran Juice <oranjuices@hotmail.com> | 2014-10-19 01:00:18 +0530 |
commit | 031ca23ce9adcdb802097f93017e4acab87d4b37 (patch) | |
tree | 50fa0c7563748b94a7c8b917f76a31d327276065 /src | |
parent | Doxygen comments in (diff) | |
download | monero-031ca23ce9adcdb802097f93017e4acab87d4b37.tar.xz |
Rewrites to old wallet file correctly
Diffstat (limited to 'src')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 14 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 5 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index bb9049015..d3b61c631 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -573,7 +573,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa "a deprecated version of the wallet. Please proceed to upgrade your wallet.\n"; std::string mnemonic_language = get_mnemonic_language(); m_wallet->set_seed_language(mnemonic_language); - m_wallet->generate(m_wallet_file, password, m_recovery_key, false, true); + m_wallet->rewrite(m_wallet_file, password); } } catch (const std::exception& e) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 013dcbcb1..b4d8068fa 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -552,7 +552,8 @@ void wallet2::load_keys(const std::string& keys_file_name, const std::string& pa * @param two_random Whether it is a non-deterministic wallet * @return The secret key of the generated wallet */ -crypto::secret_key wallet2::generate(const std::string& wallet_, const std::string& password, const crypto::secret_key& recovery_param, bool recover, bool two_random) +crypto::secret_key wallet2::generate(const std::string& wallet_, const std::string& password, + const crypto::secret_key& recovery_param, bool recover, bool two_random) { clear(); prepare_file_names(wallet_); @@ -578,6 +579,17 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const std::stri store(); return retval; } + +void wallet2::rewrite(const std::string& wallet_name, const std::string& password) +{ + prepare_file_names(wallet_name); + boost::system::error_code ignored_ec; + THROW_WALLET_EXCEPTION_IF(!boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_not_found, m_wallet_file); + THROW_WALLET_EXCEPTION_IF(!boost::filesystem::exists(m_keys_file, ignored_ec), error::file_not_found, m_keys_file); + bool r = store_keys(m_keys_file, password); + THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_keys_file); + store(); +} //---------------------------------------------------------------------------------------------------- void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists) { diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index c3dfa4df6..90b0ec331 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -133,7 +133,10 @@ namespace tools END_SERIALIZE() }; - crypto::secret_key generate(const std::string& wallet, const std::string& password, const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false, bool two_random = false); + crypto::secret_key generate(const std::string& wallet, const std::string& password, + const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false, + bool two_random = false); + void rewrite(const std::string& wallet_name, const std::string& password); void load(const std::string& wallet, const std::string& password); void store(); cryptonote::account_base& get_account(){return m_account;} |