diff options
author | Oran Juice <oranjuices@hotmail.com> | 2014-09-27 00:55:21 +0530 |
---|---|---|
committer | Oran Juice <oranjuices@hotmail.com> | 2014-09-27 00:55:21 +0530 |
commit | 262e155bab392783b4b282e3abc2d0934e196b56 (patch) | |
tree | f9403681c82db34c21e2ae8adb20e3e6936cc090 /src/simplewallet | |
parent | Supports wallet restoration (diff) | |
download | monero-262e155bab392783b4b282e3abc2d0934e196b56.tar.xz |
Throw error when word list file is empty and quick bug fix
Diffstat (limited to 'src/simplewallet')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index b368da01a..a222e7827 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -46,7 +46,7 @@ #include "version.h" #include "crypto/crypto.h" // for crypto::secret_key definition #include "mnemonics/electrum-words.h" - +#include <stdexcept> #if defined(WIN32) #include <crtdbg.h> @@ -380,10 +380,18 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) } } - if (!crypto::ElectrumWords::words_to_bytes(m_electrum_seed, m_recovery_key)) + try { - fail_msg_writer() << "electrum-style word list failed verification"; - return false; + if (!crypto::ElectrumWords::words_to_bytes(m_electrum_seed, m_recovery_key)) + { + fail_msg_writer() << "electrum-style word list failed verification"; + return false; + } + } + catch (std::runtime_error &e) + { + fail_msg_writer() << e.what() << std::endl; + return false; } } bool r = new_wallet(m_wallet_file, pwd_container.password(), m_recovery_key, m_restore_deterministic_wallet, m_non_deterministic, testnet); @@ -490,13 +498,29 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas // convert rng value to electrum-style word list std::string electrum_words; - if (m_restore_deterministic_wallet) + if (!m_restore_deterministic_wallet) { // Ask for language only if it not a wallet restore. std::string mnemonic_language = get_mnemonic_language(); - crypto::ElectrumWords::init(mnemonic_language); + try + { + crypto::ElectrumWords::init(mnemonic_language); + } + catch (std::runtime_error &e) + { + fail_msg_writer() << e.what() << std::endl; + return false; + } + } + try + { + crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words); + } + catch (std::runtime_error &e) + { + fail_msg_writer() << e.what() << std::endl; + return false; } - crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words); std::string print_electrum = ""; |