1
0
Fork 0
forked from lthn/blockchain

fixed seed info validation

This commit is contained in:
cryptozoidberg 2020-12-03 21:15:36 +01:00
parent 1e0d085727
commit 52199f1c79
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
4 changed files with 15 additions and 0 deletions

View file

@ -3379,6 +3379,12 @@ namespace tools
return wordsArray[n];
}
bool valid_word(const std::string& w)
{
auto it = wordsMap.find(w);
return it != wordsMap.end();
}
uint64_t num_by_word(const std::string& w)
{
auto it = wordsMap.find(w);

View file

@ -46,5 +46,6 @@ namespace tools
std::string binary2text(const std::vector<unsigned char>& binary);
std::string word_by_num(uint32_t n);
uint64_t num_by_word(const std::string& w);
bool valid_word(const std::string& w);
}
}

View file

@ -232,6 +232,13 @@ namespace currency
std::list<std::string> words;
boost::split(words, seed_phrase, boost::is_space());
//let's validate each word
for (const auto& w: words)
{
if (!tools::mnemonic_encoding::valid_word(words))
return false;
}
std::string timestamp_word;
if (words.size() == SEED_PHRASE_V1_WORDS_COUNT)
{

View file

@ -1989,6 +1989,7 @@ QString MainWindow::get_seed_phrase_info(const QString& param)
PREPARE_ARG_FROM_JSON(view::seed_info_param, rwtp);
PREPARE_RESPONSE(view::seed_phrase_info, ar);
ar.error_code = m_backend.get_seed_phrase_info(rwtp.seed_phrase, rwtp.seed_password, ar.response_data).c_str();
LOG_PRINT_CYAN("[get_seed_phrase_info]:" << epee::serialization::store_t_to_json(ar), LOG_LEVEL_0);
return MAKE_RESPONSE(ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}