{"action":"created","comment":{"url":"https://api.github.com/repos/monero-project/monero/pulls/comments/228739108","pull_request_review_id":169082779,"id":228739108,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODczOTEwOA==","diff_hunk":"@@ -3089,6 +3089,171 @@ namespace tools\n     }\n   }\n   //------------------------------------------------------------------------------------------------------------------------------\n+  bool wallet_rpc_server::on_restore_deterministic_wallet(const wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::request& req, wallet_rpc::COMMAND_RPC_RESTORE_DETERMINISTIC_WALLET::response& res, epee::json_rpc::error& er)\n+    {\n+    if (m_wallet_dir.empty())\n+    {\n+      er.code = WALLET_RPC_ERROR_CODE_NO_WALLET_DIR;\n+      er.message = \"No wallet dir configured\";\n+      return false;\n+    }\n+\n+    namespace po = boost::program_options;\n+    po::variables_map vm2;\n+    const char *ptr = strchr(req.filename.c_str(), '/');\n+#ifdef _WIN32\n+    if (!ptr)\n+      ptr = strchr(req.filename.c_str(), '\\\\');\n+    if (!ptr)\n+      ptr = strchr(req.filename.c_str(), ':');\n+#endif\n+    if (ptr)\n+    {\n+      er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;\n+      er.message = \"Invalid filename\";\n+      return false;\n+    }\n+    std::string m_wallet_file = m_wallet_dir + \"/\" + req.filename;\n+    std::string m_generate_new;\n+    crypto::secret_key m_recovery_key;\n+    std::string old_language;\n+    \n+    // check the given seed\n+    {\n+      if (!crypto::ElectrumWords::words_to_bytes(req.seed, m_recovery_key, old_language))\n+      {\n+        er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;\n+        er.message = \"Electrum-style word list failed verification\";\n+        return false;\n+      }\n+    }\n+\n+    // process seed_offset if given\n+    {\n+      if (!req.seed_offset.empty())\n+      {\n+        m_recovery_key = cryptonote::decrypt_key(m_recovery_key, req.seed_offset);\n+      }\n+    }\n+    {\n+      po::options_description desc(\"dummy\");\n+      const command_line::arg_descriptor<std::string, true> arg_password = {\"password\", \"password\"};\n+      const char *argv[4];\n+      int argc = 3;\n+      argv[0] = \"wallet-rpc\";\n+      argv[1] = \"--password\";\n+      argv[2] = req.password.c_str();\n+      argv[3] = NULL;\n+      vm2 = *m_vm;\n+      command_line::add_arg(desc, arg_password);\n+      po::store(po::parse_command_line(argc, argv, desc), vm2);\n+    }\n+\n+    auto rc = tools::wallet2::make_new(vm2, true, nullptr);\n+    std::unique_ptr<wallet2> wal;\n+    wal = std::move(rc.first);\n+    if (!wal)\n+    {\n+      er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;\n+      er.message = \"Failed to create wallet\";\n+      return false;\n+    }\n+\n+    epee::wipeable_string password = rc.second.password();\n+   \n+\n+    bool was_deprecated_wallet = ((old_language == crypto::ElectrumWords::old_language_name) ||\n+    crypto::ElectrumWords::get_is_old_style_seed(req.seed));\n+\n+    std::string mnemonic_language = old_language;\n+    std::string m_mnemonic_language;\n+    std::vector<std::string> language_list;\n+    crypto::ElectrumWords::get_language_list(language_list);\n+    if (mnemonic_language.empty() && std::find(language_list.begin(), language_list.end(), m_mnemonic_language) != language_list.end())\n+    {\n+      mnemonic_language = m_mnemonic_language;\n+    }\n+\n+    if (((mnemonic_language.empty() || mnemonic_language == crypto::ElectrumWords::old_language_name) && was_deprecated_wallet))\n+    {\n+      if (was_deprecated_wallet)\n+      {\n+        // The user had used an older version of the wallet with old style mnemonics.\n+        LOG_PRINT_L0(tools::wallet_rpc_server::tr(\"You had been using \"\n+          \"a deprecated version of the wallet. Please use the new seed that we provide.\\n\"));\n+      }\n+      if (req.language.empty())\n+      {\n+        er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;\n+        er.message = \"Wallet is deprecated. Would provide new seed. Please specify language to use for new seed.\";\n+        return false;\n+      }\n+      mnemonic_language = req.language;\n+      if (mnemonic_language.empty())\n+        return {};\n+    }\n+\n+    wal->set_seed_language(mnemonic_language);\n+\n+    crypto::secret_key recovery_val;\n+    try\n+    {\n+      recovery_val = wal->generate(m_wallet_file, std::move(rc.second).password(), m_recovery_key, true, false, false);\n+      LOG_PRINT_L0(tools::wallet_rpc_server::tr(\"Wallet has been restored.\\n\"));\n+    }\n+    catch (const std::exception& e)\n+    {\n+      handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);\n+      return false;\n+    }\n+\n+    // convert rng value to electrum-style word list\n+    epee::wipeable_string electrum_words;\n+    crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words, mnemonic_language);","path":"src/wallet/wallet_rpc_server.cpp","position":124,"original_position":124,"commit_id":"fc8a8a252d62ce61cbfa50d78a001d1682974d54","original_commit_id":"fc8a8a252d62ce61cbfa50d78a001d1682974d54","user":{"login":"moneromooo-monero","id":8851073,"node_id":"MDQ6VXNlcjg4NTEwNzM=","avatar_url":"https://avatars3.githubusercontent.com/u/8851073?v=4","gravatar_id":"","url":"https://api.github.com/users/moneromooo-monero","html_url":"https://github.com/moneromooo-monero","followers_url":"https://api.github.com/users/moneromooo-monero/followers","following_url":"https://api.github.com/users/moneromooo-monero/following{/other_user}","gists_url":"https://api.github.com/users/moneromooo-monero/gists{/gist_id}","starred_url":"https://api.github.com/users/moneromooo-monero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneromooo-monero/subscriptions","organizations_url":"https://api.github.com/users/moneromooo-monero/orgs","repos_url":"https://api.github.com/users/moneromooo-monero/repos","events_url":"https://api.github.com/users/moneromooo-monero/events{/privacy}","received_events_url":"https://api.github.com/users/moneromooo-monero/received_events","type":"User","site_admin":false},"body":"Doesn't test return value","created_at":"2018-10-28T08:32:19Z","updated_at":"2018-10-28T08:32:34Z","html_url":"https://github.com/monero-project/monero/pull/4746#discussion_r228739108","pull_request_url":"https://api.github.com/repos/monero-project/monero/pulls/4746","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/monero-project/monero/pulls/comments/228739108"},"html":{"href":"https://github.com/monero-project/monero/pull/4746#discussion_r228739108"},"pull_request":{"href":"https://api.github.com/repos/monero-project/monero/pulls/4746"}}},"pull_request":{"url":"https://api.github.com/repos/monero-project/monero/pulls/4746","id":226339059,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2MzM5MDU5","html_url":"https://github.com/monero-project/monero/pull/4746","diff_url":"https://github.com/monero-project/monero/pull/4746.diff","patch_url":"https://github.com/monero-project/monero/pull/4746.patch","issue_url":"https://api.github.com/repos/monero-project/monero/issues/4746","number":4746,"state":"open","locked":false,"title":"wallet_rpc: add on_restore_deterministic_wallet RPC","user":{"login":"omani","id":3346207,"node_id":"MDQ6VXNlcjMzNDYyMDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3346207?v=4","gravatar_id":"","url":"https://api.github.com/users/omani","html_url":"https://github.com/omani","followers_url":"https://api.github.com/users/omani/followers","following_url":"https://api.github.com/users/omani/following{/other_user}","gists_url":"https://api.github.com/users/omani/gists{/gist_id}","starred_url":"https://api.github.com/users/omani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omani/subscriptions","organizations_url":"https://api.github.com/users/omani/orgs","repos_url":"https://api.github.com/users/omani/repos","events_url":"https://api.github.com/users/omani/events{/privacy}","received_events_url":"https://api.github.com/users/omani/received_events","type":"User","site_admin":false},"body":"hi,\r\n\r\nthis is the on_restore_deterministic_wallet RPC call for restoring a wallet with a given seed. optionally specify restore_height, seed_offset.\r\n\r\ntakes all arguments of monero-wallet-cli when starting with --restore-deterministic-wallet:\r\n* seed\r\n* seed_offset\r\n* password\r\n* restore_height\r\n* filename (wallet name)\r\n\r\nbuild and tested successfully on Ubuntu 16.04.\r\n\r\nalso hopefully satisfies #4058 ","created_at":"2018-10-28T02:54:51Z","updated_at":"2018-10-28T08:32:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f29a90b525ab6e7ca29f778d86c584df924cfc3b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/monero-project/monero/pulls/4746/commits","review_comments_url":"https://api.github.com/repos/monero-project/monero/pulls/4746/comments","review_comment_url":"https://api.github.com/repos/monero-project/monero/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monero-project/monero/issues/4746/comments","statuses_url":"https://api.github.com/repos/monero-project/monero/statuses/fc8a8a252d62ce61cbfa50d78a001d1682974d54","head":{"label":"omani:master","ref":"master","sha":"fc8a8a252d62ce61cbfa50d78a001d1682974d54","user":{"login":"omani","id":3346207,"node_id":"MDQ6VXNlcjMzNDYyMDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3346207?v=4","gravatar_id":"","url":"https://api.github.com/users/omani","html_url":"https://github.com/omani","followers_url":"https://api.github.com/users/omani/followers","following_url":"https://api.github.com/users/omani/following{/other_user}","gists_url":"https://api.github.com/users/omani/gists{/gist_id}","starred_url":"https://api.github.com/users/omani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omani/subscriptions","organizations_url":"https://api.github.com/users/omani/orgs","repos_url":"https://api.github.com/users/omani/repos","events_url":"https://api.github.com/users/omani/events{/privacy}","received_events_url":"https://api.github.com/users/omani/received_events","type":"User","site_admin":false},"repo":{"id":155025603,"node_id":"MDEwOlJlcG9zaXRvcnkxNTUwMjU2MDM=","name":"monero","full_name":"omani/monero","private":false,"owner":{"login":"omani","id":3346207,"node_id":"MDQ6VXNlcjMzNDYyMDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3346207?v=4","gravatar_id":"","url":"https://api.github.com/users/omani","html_url":"https://github.com/omani","followers_url":"https://api.github.com/users/omani/followers","following_url":"https://api.github.com/users/omani/following{/other_user}","gists_url":"https://api.github.com/users/omani/gists{/gist_id}","starred_url":"https://api.github.com/users/omani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omani/subscriptions","organizations_url":"https://api.github.com/users/omani/orgs","repos_url":"https://api.github.com/users/omani/repos","events_url":"https://api.github.com/users/omani/events{/privacy}","received_events_url":"https://api.github.com/users/omani/received_events","type":"User","site_admin":false},"html_url":"https://github.com/omani/monero","description":"Monero: the secure, private, untraceable cryptocurrency","fork":true,"url":"https://api.github.com/repos/omani/monero","forks_url":"https://api.github.com/repos/omani/monero/forks","keys_url":"https://api.github.com/repos/omani/monero/keys{/key_id}","collaborators_url":"https://api.github.com/repos/omani/monero/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/omani/monero/teams","hooks_url":"https://api.github.com/repos/omani/monero/hooks","issue_events_url":"https://api.github.com/repos/omani/monero/issues/events{/number}","events_url":"https://api.github.com/repos/omani/monero/events","assignees_url":"https://api.github.com/repos/omani/monero/assignees{/user}","branches_url":"https://api.github.com/repos/omani/monero/branches{/branch}","tags_url":"https://api.github.com/repos/omani/monero/tags","blobs_url":"https://api.github.com/repos/omani/monero/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/omani/monero/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/omani/monero/git/refs{/sha}","trees_url":"https://api.github.com/repos/omani/monero/git/trees{/sha}","statuses_url":"https://api.github.com/repos/omani/monero/statuses/{sha}","languages_url":"https://api.github.com/repos/omani/monero/languages","stargazers_url":"https://api.github.com/repos/omani/monero/stargazers","contributors_url":"https://api.github.com/repos/omani/monero/contributors","subscribers_url":"https://api.github.com/repos/omani/monero/subscribers","subscription_url":"https://api.github.com/repos/omani/monero/subscription","commits_url":"https://api.github.com/repos/omani/monero/commits{/sha}","git_commits_url":"https://api.github.com/repos/omani/monero/git/commits{/sha}","comments_url":"https://api.github.com/repos/omani/monero/comments{/number}","issue_comment_url":"https://api.github.com/repos/omani/monero/issues/comments{/number}","contents_url":"https://api.github.com/repos/omani/monero/contents/{+path}","compare_url":"https://api.github.com/repos/omani/monero/compare/{base}...{head}","merges_url":"https://api.github.com/repos/omani/monero/merges","archive_url":"https://api.github.com/repos/omani/monero/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/omani/monero/downloads","issues_url":"https://api.github.com/repos/omani/monero/issues{/number}","pulls_url":"https://api.github.com/repos/omani/monero/pulls{/number}","milestones_url":"https://api.github.com/repos/omani/monero/milestones{/number}","notifications_url":"https://api.github.com/repos/omani/monero/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/omani/monero/labels{/name}","releases_url":"https://api.github.com/repos/omani/monero/releases{/id}","deployments_url":"https://api.github.com/repos/omani/monero/deployments","created_at":"2018-10-28T01:43:03Z","updated_at":"2018-10-28T03:00:31Z","pushed_at":"2018-10-28T03:00:29Z","git_url":"git://github.com/omani/monero.git","ssh_url":"git@github.com:omani/monero.git","clone_url":"https://github.com/omani/monero.git","svn_url":"https://github.com/omani/monero","homepage":"https://getmonero.org","size":146797,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"monero-project:master","ref":"master","sha":"4cbb476cd1f215926d3cc2b4ff6f397ffa5f347b","user":{"login":"monero-project","id":7450663,"node_id":"MDQ6VXNlcjc0NTA2NjM=","avatar_url":"https://avatars2.githubusercontent.com/u/7450663?v=4","gravatar_id":"","url":"https://api.github.com/users/monero-project","html_url":"https://github.com/monero-project","followers_url":"https://api.github.com/users/monero-project/followers","following_url":"https://api.github.com/users/monero-project/following{/other_user}","gists_url":"https://api.github.com/users/monero-project/gists{/gist_id}","starred_url":"https://api.github.com/users/monero-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monero-project/subscriptions","organizations_url":"https://api.github.com/users/monero-project/orgs","repos_url":"https://api.github.com/users/monero-project/repos","events_url":"https://api.github.com/users/monero-project/events{/privacy}","received_events_url":"https://api.github.com/users/monero-project/received_events","type":"User","site_admin":false},"repo":{"id":19316619,"node_id":"MDEwOlJlcG9zaXRvcnkxOTMxNjYxOQ==","name":"monero","full_name":"monero-project/monero","private":false,"owner":{"login":"monero-project","id":7450663,"node_id":"MDQ6VXNlcjc0NTA2NjM=","avatar_url":"https://avatars2.githubusercontent.com/u/7450663?v=4","gravatar_id":"","url":"https://api.github.com/users/monero-project","html_url":"https://github.com/monero-project","followers_url":"https://api.github.com/users/monero-project/followers","following_url":"https://api.github.com/users/monero-project/following{/other_user}","gists_url":"https://api.github.com/users/monero-project/gists{/gist_id}","starred_url":"https://api.github.com/users/monero-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monero-project/subscriptions","organizations_url":"https://api.github.com/users/monero-project/orgs","repos_url":"https://api.github.com/users/monero-project/repos","events_url":"https://api.github.com/users/monero-project/events{/privacy}","received_events_url":"https://api.github.com/users/monero-project/received_events","type":"User","site_admin":false},"html_url":"https://github.com/monero-project/monero","description":"Monero: the secure, private, untraceable cryptocurrency","fork":false,"url":"https://api.github.com/repos/monero-project/monero","forks_url":"https://api.github.com/repos/monero-project/monero/forks","keys_url":"https://api.github.com/repos/monero-project/monero/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monero-project/monero/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monero-project/monero/teams","hooks_url":"https://api.github.com/repos/monero-project/monero/hooks","issue_events_url":"https://api.github.com/repos/monero-project/monero/issues/events{/number}","events_url":"https://api.github.com/repos/monero-project/monero/events","assignees_url":"https://api.github.com/repos/monero-project/monero/assignees{/user}","branches_url":"https://api.github.com/repos/monero-project/monero/branches{/branch}","tags_url":"https://api.github.com/repos/monero-project/monero/tags","blobs_url":"https://api.github.com/repos/monero-project/monero/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monero-project/monero/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monero-project/monero/git/refs{/sha}","trees_url":"https://api.github.com/repos/monero-project/monero/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monero-project/monero/statuses/{sha}","languages_url":"https://api.github.com/repos/monero-project/monero/languages","stargazers_url":"https://api.github.com/repos/monero-project/monero/stargazers","contributors_url":"https://api.github.com/repos/monero-project/monero/contributors","subscribers_url":"https://api.github.com/repos/monero-project/monero/subscribers","subscription_url":"https://api.github.com/repos/monero-project/monero/subscription","commits_url":"https://api.github.com/repos/monero-project/monero/commits{/sha}","git_commits_url":"https://api.github.com/repos/monero-project/monero/git/commits{/sha}","comments_url":"https://api.github.com/repos/monero-project/monero/comments{/number}","issue_comment_url":"https://api.github.com/repos/monero-project/monero/issues/comments{/number}","contents_url":"https://api.github.com/repos/monero-project/monero/contents/{+path}","compare_url":"https://api.github.com/repos/monero-project/monero/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monero-project/monero/merges","archive_url":"https://api.github.com/repos/monero-project/monero/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monero-project/monero/downloads","issues_url":"https://api.github.com/repos/monero-project/monero/issues{/number}","pulls_url":"https://api.github.com/repos/monero-project/monero/pulls{/number}","milestones_url":"https://api.github.com/repos/monero-project/monero/milestones{/number}","notifications_url":"https://api.github.com/repos/monero-project/monero/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monero-project/monero/labels{/name}","releases_url":"https://api.github.com/repos/monero-project/monero/releases{/id}","deployments_url":"https://api.github.com/repos/monero-project/monero/deployments","created_at":"2014-04-30T14:38:28Z","updated_at":"2018-10-27T19:19:26Z","pushed_at":"2018-10-28T03:00:31Z","git_url":"git://github.com/monero-project/monero.git","ssh_url":"git@github.com:monero-project/monero.git","clone_url":"https://github.com/monero-project/monero.git","svn_url":"https://github.com/monero-project/monero","homepage":"https://getmonero.org","size":147055,"stargazers_count":3374,"watchers_count":3374,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1752,"mirror_url":null,"archived":false,"open_issues_count":284,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1752,"open_issues":284,"watchers":3374,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monero-project/monero/pulls/4746"},"html":{"href":"https://github.com/monero-project/monero/pull/4746"},"issue":{"href":"https://api.github.com/repos/monero-project/monero/issues/4746"},"comments":{"href":"https://api.github.com/repos/monero-project/monero/issues/4746/comments"},"review_comments":{"href":"https://api.github.com/repos/monero-project/monero/pulls/4746/comments"},"review_comment":{"href":"https://api.github.com/repos/monero-project/monero/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monero-project/monero/pulls/4746/commits"},"statuses":{"href":"https://api.github.com/repos/monero-project/monero/statuses/fc8a8a252d62ce61cbfa50d78a001d1682974d54"}},"author_association":"NONE"}}
{"actor":{"display_login":"moneromooo-monero"}}