mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 23:31:32 +02:00
add open_wallet() test hack in get_restore_height()
This commit is contained in:
@@ -812,6 +812,7 @@ namespace monero {
|
||||
MTRACE("open_wallet(...buffers...)");
|
||||
cout << "open_wallet(...buffers...)" << endl;
|
||||
monero_wallet_core* wallet = new monero_wallet_core();
|
||||
wallet->temp_http_client = http_client;
|
||||
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));
|
||||
wallet->m_w2->load("", password, keys_buffer, cache_buffer);
|
||||
@@ -825,6 +826,7 @@ namespace monero {
|
||||
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, epee::net_utils::http::abstract_http_client *http_client) {
|
||||
MTRACE("create_wallet_random(path, password, network_type, daemon_connection, language)");
|
||||
monero_wallet_core* wallet = new monero_wallet_core();
|
||||
wallet->temp_http_client = http_client;
|
||||
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));
|
||||
wallet->set_daemon_connection(daemon_connection);
|
||||
@@ -841,6 +843,8 @@ namespace monero {
|
||||
cout << "create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)" << endl;
|
||||
monero_wallet_core* wallet = new monero_wallet_core();
|
||||
|
||||
wallet->temp_http_client = http_client;
|
||||
|
||||
// validate mnemonic and get recovery key and language
|
||||
crypto::secret_key recovery_key;
|
||||
string language;
|
||||
@@ -1125,6 +1129,14 @@ namespace monero {
|
||||
}
|
||||
|
||||
uint64_t monero_wallet_core::get_restore_height() const {
|
||||
|
||||
cout << "TESTING RE-OPEN WALLET IN GET_RESTORE_HEIGHT" << endl;
|
||||
string cache_buffer = get_cache_file_buffer("supersecretpassword123");
|
||||
string keys_buffer = get_keys_file_buffer("supersecretpassword123", false);
|
||||
//http_client_wasm* http_client = new http_client_wasm();
|
||||
monero_wallet_core* wallet = monero_wallet_core::open_wallet("supersecretpassword123", monero_network_type::STAGENET, keys_buffer, cache_buffer, *get_daemon_connection(), temp_http_client);
|
||||
cout << "New wallet can be created from file data!!!" << endl;
|
||||
|
||||
return m_w2->get_refresh_from_block_height();
|
||||
}
|
||||
|
||||
@@ -3187,7 +3199,7 @@ namespace monero {
|
||||
m_w2->store_to(path, password);
|
||||
}
|
||||
|
||||
std::string monero_wallet_core::get_keys_file_buffer(const epee::wipeable_string& password, bool watch_only) {
|
||||
std::string monero_wallet_core::get_keys_file_buffer(const epee::wipeable_string& password, bool watch_only) const {
|
||||
wallet2::keys_file_data keys_file_data = {};
|
||||
bool r = m_w2->get_keys_file_data(password, watch_only, keys_file_data);
|
||||
std::string buf;
|
||||
@@ -3195,7 +3207,7 @@ namespace monero {
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string monero_wallet_core::get_cache_file_buffer(const epee::wipeable_string& password) {
|
||||
std::string monero_wallet_core::get_cache_file_buffer(const epee::wipeable_string& password) const {
|
||||
wallet2::cache_file_data cache_file_data = {};
|
||||
bool r = m_w2->get_cache_file_data(password, cache_file_data);
|
||||
|
||||
|
||||
@@ -281,12 +281,13 @@ namespace monero {
|
||||
/**
|
||||
* Wallet import and export using buffers and not the file system.
|
||||
*/
|
||||
std::string get_keys_file_buffer(const epee::wipeable_string& password, bool watch_only);
|
||||
std::string get_cache_file_buffer(const epee::wipeable_string& password);
|
||||
std::string get_keys_file_buffer(const epee::wipeable_string& password, bool watch_only) const;
|
||||
std::string get_cache_file_buffer(const epee::wipeable_string& password) const;
|
||||
|
||||
// --------------------------------- PRIVATE --------------------------------
|
||||
|
||||
private:
|
||||
epee::net_utils::http::abstract_http_client* temp_http_client;
|
||||
friend struct wallet2_listener;
|
||||
unique_ptr<tools::wallet2> m_w2; // internal wallet implementation
|
||||
unique_ptr<wallet2_listener> m_w2_listener; // internal wallet implementation listener
|
||||
|
||||
Reference in New Issue
Block a user