Accepts seed language choice from user.

This commit is contained in:
Oran Juice 2014-09-25 18:04:30 +05:30
parent 26ea53d461
commit a1ac92e185
No known key found for this signature in database
GPG key ID: 71C5AF46CCB28124
4 changed files with 59 additions and 2 deletions

View file

@ -42,6 +42,7 @@
#include <fstream>
#include "mnemonics/electrum-words.h"
#include <stdexcept>
#include <boost/filesystem.hpp>
namespace
{
@ -82,7 +83,7 @@ namespace crypto
namespace ElectrumWords
{
void init(const std::string &language, bool old_word_list = false)
void init(const std::string &language, bool old_word_list)
{
if (old_word_list)
{
@ -188,6 +189,22 @@ namespace crypto
return false;
}
void get_language_list(std::vector<std::string> &languages)
{
languages.clear();
boost::filesystem::path languages_directory("wordlists/languages");
if (!boost::filesystem::exists(languages_directory) ||
!boost::filesystem::is_directory(languages_directory))
{
throw std::runtime_error("Word list languages directory is missing.");
}
boost::filesystem::directory_iterator end;
for (boost::filesystem::directory_iterator it(languages_directory); it != end; it++)
{
languages.push_back(it->path().filename().string());
}
}
} // namespace ElectrumWords
} // namespace crypto

View file

@ -41,8 +41,9 @@ namespace crypto
{
namespace ElectrumWords
{
void init(const std::string &language, bool old_word_list);
void init(const std::string &language, bool old_word_list=false);
bool words_to_bytes(const std::string& words, crypto::secret_key& dst);
bool bytes_to_words(const crypto::secret_key& src, std::string& words);
void get_language_list(std::vector<std::string> &languages);
}
}