mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 01:48:52 +00:00
Merge pull request #7430
064eeb2
wallet_rpc_server: set seed language in generate_from_keys (moneromooo-monero)
This commit is contained in:
commit
e1d987aa66
@ -491,6 +491,14 @@ namespace crypto
|
|||||||
return "<language not found>";
|
return "<language not found>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_valid_language(const std::string &language)
|
||||||
|
{
|
||||||
|
const std::vector<const Language::Base*> language_instances = get_language_list();
|
||||||
|
for (std::vector<const Language::Base*>::const_iterator it = language_instances.begin(); it != language_instances.end(); it++)
|
||||||
|
if ((*it)->get_english_language_name() == language || (*it)->get_language_name() == language)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,8 @@ namespace crypto
|
|||||||
* \return the name of the language in English
|
* \return the name of the language in English
|
||||||
*/
|
*/
|
||||||
std::string get_english_name_for(const std::string &name);
|
std::string get_english_name_for(const std::string &name);
|
||||||
|
|
||||||
|
bool is_valid_language(const std::string &language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3154,17 +3154,7 @@ namespace tools
|
|||||||
}
|
}
|
||||||
std::string wallet_file = req.filename.empty() ? "" : (m_wallet_dir + "/" + req.filename);
|
std::string wallet_file = req.filename.empty() ? "" : (m_wallet_dir + "/" + req.filename);
|
||||||
{
|
{
|
||||||
std::vector<std::string> languages;
|
if (!crypto::ElectrumWords::is_valid_language(req.language))
|
||||||
crypto::ElectrumWords::get_language_list(languages, false);
|
|
||||||
std::vector<std::string>::iterator it;
|
|
||||||
|
|
||||||
it = std::find(languages.begin(), languages.end(), req.language);
|
|
||||||
if (it == languages.end())
|
|
||||||
{
|
|
||||||
crypto::ElectrumWords::get_language_list(languages, true);
|
|
||||||
it = std::find(languages.begin(), languages.end(), req.language);
|
|
||||||
}
|
|
||||||
if (it == languages.end())
|
|
||||||
{
|
{
|
||||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||||
er.message = "Unknown language: " + req.language;
|
er.message = "Unknown language: " + req.language;
|
||||||
@ -3582,6 +3572,17 @@ namespace tools
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!req.language.empty())
|
||||||
|
{
|
||||||
|
if (!crypto::ElectrumWords::is_valid_language(req.language))
|
||||||
|
{
|
||||||
|
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||||
|
er.message = "The specified seed language is invalid.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wal->set_seed_language(req.language);
|
||||||
|
}
|
||||||
|
|
||||||
// set blockheight if given
|
// set blockheight if given
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -3725,12 +3726,7 @@ namespace tools
|
|||||||
er.message = "Wallet was using the old seed language. You need to specify a new seed language.";
|
er.message = "Wallet was using the old seed language. You need to specify a new seed language.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<std::string> language_list;
|
if (!crypto::ElectrumWords::is_valid_language(req.language))
|
||||||
std::vector<std::string> language_list_en;
|
|
||||||
crypto::ElectrumWords::get_language_list(language_list);
|
|
||||||
crypto::ElectrumWords::get_language_list(language_list_en, true);
|
|
||||||
if (std::find(language_list.begin(), language_list.end(), req.language) == language_list.end() &&
|
|
||||||
std::find(language_list_en.begin(), language_list_en.end(), req.language) == language_list_en.end())
|
|
||||||
{
|
{
|
||||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||||
er.message = "Wallet was using the old seed language, and the specified new seed language is invalid.";
|
er.message = "Wallet was using the old seed language, and the specified new seed language is invalid.";
|
||||||
|
@ -2214,6 +2214,7 @@ namespace wallet_rpc
|
|||||||
std::string viewkey;
|
std::string viewkey;
|
||||||
std::string password;
|
std::string password;
|
||||||
bool autosave_current;
|
bool autosave_current;
|
||||||
|
std::string language;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_OPT(restore_height, (uint64_t)0)
|
KV_SERIALIZE_OPT(restore_height, (uint64_t)0)
|
||||||
@ -2223,6 +2224,7 @@ namespace wallet_rpc
|
|||||||
KV_SERIALIZE(viewkey)
|
KV_SERIALIZE(viewkey)
|
||||||
KV_SERIALIZE(password)
|
KV_SERIALIZE(password)
|
||||||
KV_SERIALIZE_OPT(autosave_current, true)
|
KV_SERIALIZE_OPT(autosave_current, true)
|
||||||
|
KV_SERIALIZE(language)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user