@@ -1059,23 +1059,33 @@ namespace monero {
10591059 return key_file_exists;
10601060 }
10611061
1062- monero_wallet_full* monero_wallet_full::open_wallet (const std::string& path, const std::string& password, const monero_network_type network_type) {
1062+ monero_wallet_full* monero_wallet_full::open_wallet (const std::string& path, const std::string& password, const monero_network_type network_type, bool regtest ) {
10631063 MTRACE (" open_wallet(" << path << " , ***, " << network_type << " )" );
10641064 monero_wallet_full* wallet = new monero_wallet_full ();
10651065 wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(network_type), 1 , true ));
10661066 wallet->m_w2 ->load (path, password);
10671067 wallet->m_w2 ->init (" " );
1068+ if (regtest) {
1069+ if (network_type != monero_network_type::MAINNET) throw std::runtime_error (" Network type must be mainnet when using regtest option" );
1070+ wallet->m_w2 ->allow_mismatched_daemon_version (true );
1071+ wallet->m_w2 ->max_reorg_depth (100000 );
1072+ }
10681073 wallet->init_common ();
10691074 return wallet;
10701075 }
10711076
1072- monero_wallet_full* monero_wallet_full::open_wallet_data (const std::string& password, const monero_network_type network_type, const std::string& keys_data, const std::string& cache_data, const monero_rpc_connection& daemon_connection, std::unique_ptr<epee::net_utils::http::http_client_factory> http_client_factory) {
1077+ monero_wallet_full* monero_wallet_full::open_wallet_data (const std::string& password, const monero_network_type network_type, const std::string& keys_data, const std::string& cache_data, const monero_rpc_connection& daemon_connection, std::unique_ptr<epee::net_utils::http::http_client_factory> http_client_factory, bool regtest ) {
10731078 MTRACE (" open_wallet_data(...)" );
10741079 monero_wallet_full* wallet = new monero_wallet_full ();
10751080 if (http_client_factory == nullptr ) wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(network_type), 1 , true ));
10761081 else wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(network_type), 1 , true , std::move (http_client_factory)));
10771082 wallet->m_w2 ->load (" " , password, keys_data, cache_data);
10781083 wallet->m_w2 ->init (" " );
1084+ if (regtest) {
1085+ if (network_type != monero_network_type::MAINNET) throw std::runtime_error (" Network type must be mainnet when using regtest option" );
1086+ wallet->m_w2 ->allow_mismatched_daemon_version (true );
1087+ wallet->m_w2 ->max_reorg_depth (100000 );
1088+ }
10791089 wallet->set_daemon_connection (daemon_connection);
10801090 wallet->init_common ();
10811091 return wallet;
@@ -1100,6 +1110,7 @@ namespace monero {
11001110 if (config_normalized.m_language .get ().empty ()) config_normalized.m_language = std::string (" English" );
11011111 if (!monero_utils::is_valid_language (config_normalized.m_language .get ())) throw std::runtime_error (" Unknown language: " + config_normalized.m_language .get ());
11021112 if (config.m_network_type == boost::none) throw std::runtime_error (" Must provide wallet network type" );
1113+ if (config.m_regtest != boost::none && *config.m_regtest == true && *config.m_network_type != monero_network_type::MAINNET) throw std::runtime_error (" Network type must be mainnet when using regtest option" );
11031114
11041115 // create wallet
11051116 if (!config_normalized.m_seed .get ().empty ()) {
@@ -1137,6 +1148,10 @@ namespace monero {
11371148 if (http_client_factory == nullptr ) wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(config.m_network_type .get ()), 1 , true ));
11381149 else wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(config.m_network_type .get ()), 1 , true , std::move (http_client_factory)));
11391150 wallet->m_w2 ->init (" " );
1151+ if (config.m_regtest != boost::none && config.m_regtest .get () == true ) {
1152+ wallet->m_w2 ->allow_mismatched_daemon_version (true );
1153+ wallet->m_w2 ->max_reorg_depth (100000 );
1154+ }
11401155 wallet->set_daemon_connection (config.m_server );
11411156 wallet->m_w2 ->set_seed_language (language);
11421157 if (config.m_account_lookahead != boost::none) wallet->m_w2 ->set_subaddress_lookahead (config.m_account_lookahead .get (), config.m_subaddress_lookahead .get ());
@@ -1232,6 +1247,10 @@ namespace monero {
12321247 else if (has_spend_key) wallet->m_w2 ->generate (config.m_path .get (), config.m_password .get (), spend_key_sk, true , false );
12331248 else wallet->m_w2 ->generate (config.m_path .get (), config.m_password .get (), address_info.address , view_key_sk);
12341249 wallet->m_w2 ->init (" " );
1250+ if (config.m_regtest != boost::none && config.m_regtest .get () == true ) {
1251+ wallet->m_w2 ->allow_mismatched_daemon_version (true );
1252+ wallet->m_w2 ->max_reorg_depth (100000 );
1253+ }
12351254 wallet->set_daemon_connection (config.m_server );
12361255 wallet->m_w2 ->set_refresh_from_block_height (config.m_restore_height .get ());
12371256 wallet->m_w2 ->set_seed_language (config.m_language .get ());
@@ -1251,6 +1270,10 @@ namespace monero {
12511270 if (http_client_factory == nullptr ) wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(config.m_network_type .get ()), 1 , true ));
12521271 else wallet->m_w2 = std::unique_ptr<tools::wallet2>(new tools::wallet2 (static_cast <cryptonote::network_type>(config.m_network_type .get ()), 1 , true , std::move (http_client_factory)));
12531272 wallet->m_w2 ->init (" " );
1273+ if (config.m_regtest != boost::none && config.m_regtest .get () == true ) {
1274+ wallet->m_w2 ->allow_mismatched_daemon_version (true );
1275+ wallet->m_w2 ->max_reorg_depth (100000 );
1276+ }
12541277 wallet->set_daemon_connection (config.m_server );
12551278 wallet->m_w2 ->set_seed_language (config.m_language .get ());
12561279 crypto::secret_key secret_key;
0 commit comments