forked from lthn/blockchain
fixed seed info validation
This commit is contained in:
parent
7b4a6fa90a
commit
0a22f94030
4 changed files with 15 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue