From 93390bed3ae0e27688e581e39e9abbf1291fde22 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 21 Aug 2019 09:57:55 -0400 Subject: [PATCH] revert_open wallet to not use vm and make_from_json --- src/wallet/monero_wallet.cpp | 108 ++--------------------------------- 1 file changed, 6 insertions(+), 102 deletions(-) diff --git a/src/wallet/monero_wallet.cpp b/src/wallet/monero_wallet.cpp index 07b47d6..9f73912 100644 --- a/src/wallet/monero_wallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -813,107 +813,11 @@ namespace monero { monero_wallet* monero_wallet::open_wallet(const string& path, const string& password, const monero_network_type network_type) { MTRACE("open_wallet(" << path << ", " << password << ", " << network_type << ")"); monero_wallet* wallet = new monero_wallet(); - - - - cout << "1" << endl; - - -// const boost::program_options::variables_map *m_vm; - -// po::options_description desc_params(wallet_args::tr("Wallet options")); -// tools::wallet2::init_options(desc_params); - - -// po::options_description desc_params(wallet_args::tr("Wallet options")); -// tools::wallet2::init_options(desc_params); -// command_line::add_arg(desc_params, arg_rpc_bind_port); -// command_line::add_arg(desc_params, arg_disable_rpc_login); -// command_line::add_arg(desc_params, arg_restricted); -// cryptonote::rpc_args::init_options(desc_params); -// command_line::add_arg(desc_params, arg_wallet_file); -// command_line::add_arg(desc_params, arg_from_json); -// command_line::add_arg(desc_params, arg_wallet_dir); -// command_line::add_arg(desc_params, arg_prompt_for_password); - - const boost::program_options::variables_map vm; - - cout << "2" << endl; - - namespace po = boost::program_options; - cout << "3" << endl; - po::variables_map vm2; - cout << "4" << endl; -// const char *ptr = strchr(path.c_str(), '/'); -//#ifdef _WIN32 -// if (!ptr) -// ptr = strchr(req.filename.c_str(), '\\'); -// if (!ptr) -// ptr = strchr(req.filename.c_str(), ':'); -//#endif -// if (ptr) -// { -// throw runtime_error("Invalid filename"); -// } - { - po::options_description desc("dummy"); - tools::wallet2::init_options(desc); -// const command_line::arg_descriptor arg_password = {"password", "password!"}; -// command_line::add_arg(desc, arg_password); -// const command_line::arg_descriptor arg_stagenet = {"stagenet", "stagenet!"}; -// command_line::add_arg(desc, arg_stagenet); -// const command_line::arg_descriptor arg_testnet = {"testnet", "testnet!"}; -// command_line::add_arg(desc, arg_testnet); - cout << "6" << endl; - - const char *argv[5]; - cout << "7" << endl; - int argc = 5; - cout << "8" << endl; - argv[0] = "wallet-rpc"; - cout << "9" << endl; - argv[1] = "--password"; - cout << "10" << endl; - argv[2] = password.c_str(); - cout << "11" << endl; - argv[3] = network_type == monero_network_type::STAGENET ? "--stagenet" : network_type == monero_network_type::TESTNET ? "--testnet" : ""; - cout << "12" << endl; - //argv[4] = "--daemon-address"; - //argv[5] = ""; - argv[4] = ""; - cout << "13" << endl; - vm2 = vm; - cout << "14" << endl; - - po::store(po::parse_command_line(argc, argv, desc), vm2); - - cout << "15" << endl; - - bool has_stagenet = tools::wallet2::has_stagenet_option(vm2); - cout << "Has stagenet: " << has_stagenet << endl; - } - - wallet->m_w2 = nullptr; - try { - string path_copy = path; - cout << "Opening path: " << path_copy << endl; - wallet->m_w2 = tools::wallet2::make_from_file(vm2, true, path_copy, nullptr).first; - } - catch (const std::exception& e) - { - throw runtime_error(string("Error making wallet from file: ") + e.what()); - } - if (!wallet->m_w2) - { - throw runtime_error("Failed to open wallet"); - } - - - - //wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true)); - //wallet->m_w2->load(path, password); - //wallet->m_w2->init(""); - //wallet->m_w2->set_ring_database(get_default_ringdb_path(wallet->m_w2->nettype())); + MTRACE("open_wallet(" << path << ", " << password << ", " << network_type << ")"); + monero_wallet* wallet = new monero_wallet(); + wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true)); + wallet->m_w2->load(path, password); + wallet->m_w2->init(""); wallet->init_common(); return wallet; } @@ -933,7 +837,7 @@ namespace monero { crypto::secret_key secret_key; wallet->m_w2->generate(path, password, secret_key, false, false); wallet->init_common(); - if (wallet->is_connected()) wallet->m_w2->set_refresh_from_block_height(wallet->get_daemon_height()); // TODO: necessary? test + if (wallet->is_connected()) wallet->m_w2->set_refresh_from_block_height(wallet->get_daemon_height()); return wallet; }