mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
Throw error when word list file is empty and quick bug fix
This commit is contained in:
parent
3c0e87e1b6
commit
262e155bab
@ -63,6 +63,7 @@ namespace
|
||||
{
|
||||
words_array.clear();
|
||||
words_map.clear();
|
||||
num_words = 0;
|
||||
std::ifstream input_stream;
|
||||
input_stream.open(word_file.c_str(), std::ifstream::in);
|
||||
|
||||
@ -109,8 +110,8 @@ namespace crypto
|
||||
}
|
||||
if (num_words == 0)
|
||||
{
|
||||
throw std::runtime_error(std::string("Word list file is corrupt: ") +
|
||||
old_word_list ? OLD_WORD_FILE : (LANGUAGES_DIRECTORY + '/' + language));
|
||||
throw std::runtime_error(std::string("Word list file is empty: ") +
|
||||
(old_word_list ? OLD_WORD_FILE : (LANGUAGES_DIRECTORY + '/' + language)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,13 +129,16 @@ namespace crypto
|
||||
boost::split(wlist, words, boost::is_any_of(" "));
|
||||
|
||||
std::vector<std::string> languages;
|
||||
get_language_list(languages);
|
||||
|
||||
std::vector<std::string>::iterator it;
|
||||
get_language_list(languages);
|
||||
for (it = languages.begin(); it != languages.end() &&
|
||||
!word_list_file_match(wlist); it++)
|
||||
for (it = languages.begin(); it != languages.end(); it++)
|
||||
{
|
||||
init(*it);
|
||||
if (word_list_file_match(wlist))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (it == languages.end())
|
||||
{
|
||||
|
@ -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,12 +380,20 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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);
|
||||
CHECK_AND_ASSERT_MES(r, false, "account creation failed");
|
||||
}
|
||||
@ -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();
|
||||
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;
|
||||
}
|
||||
|
||||
std::string print_electrum = "";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user