monero_wallet_core accepts http_client param;

ready to define Asyncify
This commit is contained in:
woodser
2019-12-27 11:28:08 -05:00
parent c8b3bb22f6
commit d0dc16dc76
2 changed files with 18 additions and 6 deletions
+17 -5
View File
@@ -821,8 +821,9 @@ 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) {
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, epee::net_utils::http::abstract_http_client *http_client) {
MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)");
cout << "create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)" << endl;
monero_wallet_core* wallet = new monero_wallet_core();
// validate mnemonic and get recovery key and language
@@ -836,12 +837,20 @@ namespace monero {
if (!seed_offset.empty()) recovery_key = cryptonote::decrypt_key(recovery_key, seed_offset);
// initialize wallet
wallet->m_w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
cout << "1" << endl;
if (http_client == nullptr) wallet->m_w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
else wallet->m_w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true, http_client));
cout << "2" << endl;
wallet->set_daemon_connection(daemon_connection);
cout << "3" << endl;
wallet->m_w2->set_seed_language(language);
cout << "4" << endl;
wallet->m_w2->generate(path, password, recovery_key, true, false);
cout << "5" << endl;
wallet->m_w2->set_refresh_from_block_height(restore_height);
cout << "6" << endl;
wallet->init_common();
cout << "7" << endl;
return wallet;
}
@@ -922,9 +931,12 @@ namespace monero {
// prepare uri, login, and is_trusted for wallet2
boost::optional<epee::net_utils::http::login> login{};
login.emplace(username, password);
bool is_trusted = false;
try { is_trusted = tools::is_local_address(uri); } // wallet is trusted iff local
catch (const exception &e) { }
bool is_trusted = true;
// TODO: is_local_address() uses common/util which requires libunbound
// bool is_trusted = false;
// try { is_trusted = tools::is_local_address(uri); } // wallet is trusted iff local
// catch (const exception &e) { }
// init wallet2 and set daemon connection
if (!m_w2->init(uri, login)) throw runtime_error("Failed to initialize wallet with daemon connection");
+1 -1
View File
@@ -121,7 +121,7 @@ namespace monero {
* @param restore_height is the block height to restore (i.e. scan the chain) 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
*/
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, uint64_t restore_height, const string& seed_offset);
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, uint64_t restore_height, const string& seed_offset, epee::net_utils::http::abstract_http_client *http_client = nullptr);
/**
* Create a wallet from an address, view key, and spend key.