diff --git a/src/wallet/monero_wallet_core.cpp b/src/wallet/monero_wallet_core.cpp index f62ae01..4af50ef 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, unique_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_factory) { 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, std::move(http_client))); + if (http_client_factory == 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, std::move(http_client_factory))); 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, unique_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_factory) { 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, std::move(http_client))); + if (http_client_factory == 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, std::move(http_client_factory))); 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, unique_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_factory) { MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)"); monero_wallet_core* wallet = new monero_wallet_core(); @@ -851,8 +851,8 @@ namespace monero { if (!seed_offset.empty()) recovery_key = cryptonote::decrypt_key(recovery_key, seed_offset); // 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, std::move(http_client))); + if (http_client_factory == 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, std::move(http_client_factory))); 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, unique_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_factory) { 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(); @@ -908,8 +908,8 @@ 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, std::move(http_client))); + if (http_client_factory == 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, std::move(http_client_factory))); 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 f948cce..5f8833c 100644 --- a/src/wallet/monero_wallet_core.h +++ b/src/wallet/monero_wallet_core.h @@ -108,10 +108,10 @@ namespace monero { * @param keys_data contains the contents of the ".keys" file * @param cache_data contains the contents of the wallet cache file (no extension) * @param daemon_connection is connection information to a daemon (default = an unconnected wallet) - * @param http_client allows the http client to be overriden (defaults to monero-project's http_client.h) + * @param http_client_factory allows use of custom http clients * @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(), unique_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_factory = nullptr); /** * Create a new wallet with a randomly generated seed. @@ -121,10 +121,10 @@ namespace monero { * @param network_type is the wallet's network type's * @param daemon_connection is connection information to a daemon (defaults to an unconnected wallet) * @param language is the wallet and mnemonic's language (defaults to "English") - * @param http_client allows the http client to be overriden (defaults to monero-project's http_client.h) + * @param http_client_factory allows use of custom http clients * @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", unique_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_factory = nullptr); /** * Create a wallet from an existing mnemonic phrase. @@ -135,10 +135,10 @@ namespace monero { * @param daemon_connection is connection information to a daemon (defaults to an unconnected wallet) * @param restore_height is the block height to restore from (default = 0) * @param seed_offset is the offset used to derive a new seed from the given mnemonic to recover a secret wallet from the mnemonic phrase (default = "") - * @param http_client allows the http client to be overriden (defaults to monero-project's http_client.h) + * @param http_client_factory allows use of custom http clients * @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 = "", unique_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_factory = nullptr); /** * Create a wallet from an address, view key, and spend key. @@ -152,9 +152,10 @@ namespace monero { * @param daemon_connection is connection information to a daemon (defaults to an unconnected wallet) * @param restore_height is the block height to restore (i.e. scan the chain) from (default = 0) * @param language is the wallet and mnemonic's language (defaults to "English") + * @param http_client_factory allows use of custom http clients * @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", unique_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_factory = nullptr); /** * Get a list of available languages for the wallet's mnemonic phrase.