aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-03-29 22:37:19 -0400
committerluigi1111 <luigi1111w@gmail.com>2021-03-29 22:37:19 -0400
commite1d987aa660e728619b8ac48a2e11f83a2cc6803 (patch)
tree0be928b295600993440a7e1432f346445f50b935 /src/wallet
parentMerge pull request #7636 (diff)
parentwallet_rpc_server: set seed language in generate_from_keys (diff)
downloadmonero-e1d987aa660e728619b8ac48a2e11f83a2cc6803.tar.xz
Merge pull request #7430
064eeb2 wallet_rpc_server: set seed language in generate_from_keys (moneromooo-monero)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet_rpc_server.cpp30
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h2
2 files changed, 15 insertions, 17 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index b09e24d31..1af832bb3 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -3154,17 +3154,7 @@ 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, 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())
+ if (!crypto::ElectrumWords::is_valid_language(req.language))
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "Unknown language: " + req.language;
@@ -3582,6 +3572,17 @@ namespace tools
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
try
{
@@ -3725,12 +3726,7 @@ namespace tools
er.message = "Wallet was using the old seed language. You need to specify a new seed language.";
return false;
}
- std::vector<std::string> language_list;
- 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())
+ if (!crypto::ElectrumWords::is_valid_language(req.language))
{
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.";
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index abc7702f7..0002508a2 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -2214,6 +2214,7 @@ namespace wallet_rpc
std::string viewkey;
std::string password;
bool autosave_current;
+ std::string language;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_OPT(restore_height, (uint64_t)0)
@@ -2223,6 +2224,7 @@ namespace wallet_rpc
KV_SERIALIZE(viewkey)
KV_SERIALIZE(password)
KV_SERIALIZE_OPT(autosave_current, true)
+ KV_SERIALIZE(language)
END_KV_SERIALIZE_MAP()
};