From 500667049e08cb4e3b83f133b3d63958f94338e7 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 23 Feb 2020 20:59:11 -0500 Subject: [PATCH] change m_http_client from shared_ptr to unique_ptr --- src/wallet/monero_wallet_core.cpp | 16 ++++++++-------- src/wallet/monero_wallet_core.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/wallet/monero_wallet_core.cpp b/src/wallet/monero_wallet_core.cpp index 0ec88cc..780d2a0 100644 --- a/src/wallet/monero_wallet_core.cpp +++ b/src/wallet/monero_wallet_core.cpp @@ -809,12 +809,12 @@ namespace monero { return wallet; } - monero_wallet_core* monero_wallet_core::open_wallet(const string& password, const monero_network_type network_type, const string& keys_data, const string& cache_data, const monero_rpc_connection& daemon_connection, shared_ptr http_client) { + monero_wallet_core* monero_wallet_core::open_wallet(const string& password, const monero_network_type network_type, const string& keys_data, const string& cache_data, const monero_rpc_connection& daemon_connection, unique_ptr http_client) { MTRACE("open_wallet(...buffers...)"); cout << "open_wallet(...buffers...)" << endl; monero_wallet_core* wallet = new monero_wallet_core(); if (http_client == nullptr) wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true)); - else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, http_client)); + else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, std::move(http_client))); wallet->m_w2->load("", password, keys_data, cache_data); wallet->m_w2->init(""); wallet->set_daemon_connection(daemon_connection); @@ -822,11 +822,11 @@ namespace monero { return wallet; } - monero_wallet_core* monero_wallet_core::create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection, const string& language, shared_ptr http_client) { + monero_wallet_core* monero_wallet_core::create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection, const string& language, unique_ptr http_client) { MTRACE("create_wallet_random(path, password, network_type, daemon_connection, language)"); monero_wallet_core* wallet = new monero_wallet_core(); if (http_client == nullptr) wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true)); - else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, http_client)); + else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, std::move(http_client))); wallet->set_daemon_connection(daemon_connection); wallet->m_w2->set_seed_language(language); crypto::secret_key secret_key; @@ -836,7 +836,7 @@ namespace monero { return wallet; } - monero_wallet_core* monero_wallet_core::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& seed_offset, shared_ptr http_client) { + monero_wallet_core* monero_wallet_core::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& seed_offset, unique_ptr http_client) { MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)"); monero_wallet_core* wallet = new monero_wallet_core(); @@ -852,7 +852,7 @@ namespace monero { // initialize wallet if (http_client == nullptr) wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true)); - else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, http_client)); + else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, std::move(http_client))); wallet->set_daemon_connection(daemon_connection); wallet->m_w2->set_seed_language(language); wallet->m_w2->generate(path, password, recovery_key, true, false); @@ -861,7 +861,7 @@ namespace monero { return wallet; } - monero_wallet_core* monero_wallet_core::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language, shared_ptr http_client) { + monero_wallet_core* monero_wallet_core::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language, unique_ptr http_client) { MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type, daemon_connection, restore_height, language)"); monero_wallet_core* wallet = new monero_wallet_core(); @@ -909,7 +909,7 @@ namespace monero { // initialize wallet if (http_client == nullptr) wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true)); - else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, http_client)); + else wallet->m_w2 = unique_ptr(new tools::wallet2(static_cast(network_type), 1, true, std::move(http_client))); if (has_spend_key && has_view_key) wallet->m_w2->generate(path, password, info.address, spend_key_sk, view_key_sk); else if (has_spend_key) wallet->m_w2->generate(path, password, spend_key_sk, true, false); else wallet->m_w2->generate(path, password, info.address, view_key_sk); diff --git a/src/wallet/monero_wallet_core.h b/src/wallet/monero_wallet_core.h index 968968f..e8252e0 100644 --- a/src/wallet/monero_wallet_core.h +++ b/src/wallet/monero_wallet_core.h @@ -111,7 +111,7 @@ namespace monero { * @param http_client allows the http client to be overriden (defaults to monero-project's http_client.h) * @return a pointer to the wallet instance */ - static monero_wallet_core* open_wallet(const string& password, const monero_network_type, const string& keys_data, const string& cache_data, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), shared_ptr http_client = nullptr); + static monero_wallet_core* open_wallet(const string& password, const monero_network_type, const string& keys_data, const string& cache_data, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), unique_ptr http_client = nullptr); /** * Create a new wallet with a randomly generated seed. @@ -124,7 +124,7 @@ namespace monero { * @param http_client allows the http client to be overriden (defaults to monero-project's http_client.h) * @return a pointer to the wallet instance */ - static monero_wallet_core* create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), const string& language = "English", shared_ptr http_client = nullptr); + static monero_wallet_core* create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), const string& language = "English", unique_ptr http_client = nullptr); /** * Create a wallet from an existing mnemonic phrase. @@ -138,7 +138,7 @@ namespace monero { * @param http_client allows the http client to be overriden (defaults to monero-project's http_client.h) * @return a pointer to the wallet instance */ - static monero_wallet_core* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), uint64_t restore_height = 0, const string& seed_offset = "", shared_ptr http_client = nullptr); + static monero_wallet_core* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), uint64_t restore_height = 0, const string& seed_offset = "", unique_ptr http_client = nullptr); /** * Create a wallet from an address, view key, and spend key. @@ -154,7 +154,7 @@ namespace monero { * @param language is the wallet and mnemonic's language (defaults to "English") * @return a pointer to the wallet instance */ - static monero_wallet_core* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), uint64_t restore_height = 0, const string& language = "English", shared_ptr http_client = nullptr); + static monero_wallet_core* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection = monero_rpc_connection(), uint64_t restore_height = 0, const string& language = "English", unique_ptr http_client = nullptr); /** * Get a list of available languages for the wallet's mnemonic phrase.