Merge pull request #5345

678262ab wallet_rpc_server: allow english/local language names in create_wallet (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-04-06 15:59:10 +02:00
commit 7e5651c346
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
2 changed files with 12 additions and 4 deletions

View file

@ -2916,7 +2916,8 @@ namespace tools
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_get_languages(const wallet_rpc::COMMAND_RPC_GET_LANGUAGES::request& req, wallet_rpc::COMMAND_RPC_GET_LANGUAGES::response& res, epee::json_rpc::error& er, const connection_context *ctx)
{
crypto::ElectrumWords::get_language_list(res.languages);
crypto::ElectrumWords::get_language_list(res.languages, true);
crypto::ElectrumWords::get_language_list(res.languages_local, false);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
@ -2947,14 +2948,19 @@ namespace tools
std::string wallet_file = req.filename.empty() ? "" : (m_wallet_dir + "/" + req.filename);
{
std::vector<std::string> languages;
crypto::ElectrumWords::get_language_list(languages);
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.message = "Unknown language";
er.message = "Unknown language: " + req.language;
return false;
}
}

View file

@ -47,7 +47,7 @@
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define WALLET_RPC_VERSION_MAJOR 1
#define WALLET_RPC_VERSION_MINOR 8
#define WALLET_RPC_VERSION_MINOR 9
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
namespace tools
@ -1999,9 +1999,11 @@ namespace wallet_rpc
struct response_t
{
std::vector<std::string> languages;
std::vector<std::string> languages_local;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(languages)
KV_SERIALIZE(languages_local)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<response_t> response;