mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-22 20:58:54 +00:00
Accepts seed language choice from user.
This commit is contained in:
parent
26ea53d461
commit
a1ac92e185
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -430,6 +430,39 @@ bool simple_wallet::try_connect_to_daemon()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string simple_wallet::get_mnemonic_language()
|
||||
{
|
||||
std::vector<std::string> language_list;
|
||||
std::string language_choice;
|
||||
int language_number = -1;
|
||||
crypto::ElectrumWords::get_language_list(language_list);
|
||||
std::cout << "List of available languages for your wallet's seed:" << std::endl;
|
||||
int ii;
|
||||
std::vector<std::string>::iterator it;
|
||||
for (it = language_list.begin(), ii = 0; it != language_list.end(); it++, ii++)
|
||||
{
|
||||
std::cout << ii << " : " << *it << std::endl;
|
||||
}
|
||||
while (language_number < 0)
|
||||
{
|
||||
language_choice = command_line::input_line("Enter the number corresponding to the language of your choice: ");
|
||||
try
|
||||
{
|
||||
language_number = std::stoi(language_choice);
|
||||
if (!((language_number >= 0) && (static_cast<uint>(language_number) < language_list.size())))
|
||||
{
|
||||
language_number = -1;
|
||||
fail_msg_writer() << "Invalid language choice passed. Please try again.\n";
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
fail_msg_writer() << "Invalid language choice passed. Please try again.\n";
|
||||
}
|
||||
}
|
||||
return language_list[language_number];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::new_wallet(const string &wallet_file, const std::string& password, const crypto::secret_key& recovery_key, bool recover, bool two_random, bool testnet)
|
||||
{
|
||||
@ -456,6 +489,11 @@ 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;
|
||||
std::string mnemonic_language = get_mnemonic_language();
|
||||
|
||||
std::cout << "(" << (mnemonic_language) << ")" << std::endl;
|
||||
|
||||
crypto::ElectrumWords::init(mnemonic_language);
|
||||
crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words);
|
||||
|
||||
std::string print_electrum = "";
|
||||
|
@ -92,6 +92,7 @@ namespace cryptonote
|
||||
uint64_t get_daemon_blockchain_height(std::string& err);
|
||||
bool try_connect_to_daemon();
|
||||
bool ask_wallet_create_if_needed();
|
||||
std::string get_mnemonic_language();
|
||||
|
||||
//----------------- i_wallet2_callback ---------------------
|
||||
virtual void on_new_block(uint64_t height, const cryptonote::block& block);
|
||||
|
Loading…
Reference in New Issue
Block a user