diff options
Diffstat (limited to 'src/simplewallet')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 19 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.h | 4 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index e822e6636..4312981e2 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -72,6 +72,7 @@ namespace const command_line::arg_descriptor<bool> arg_non_deterministic = {"non-deterministic", "creates non-deterministic view and spend keys", false}; const command_line::arg_descriptor<int> arg_daemon_port = {"daemon-port", "Use daemon instance at port <arg> instead of 8081", 0}; const command_line::arg_descriptor<uint32_t> arg_log_level = {"set_log", "", 0, true}; + const command_line::arg_descriptor<bool> arg_testnet = {"testnet", "Used to deploy test nets. The daemon must be launched with --testnet flag", false}; const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""}; @@ -334,6 +335,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) if (m_daemon_address.empty()) m_daemon_address = std::string("http://") + m_daemon_host + ":" + std::to_string(m_daemon_port); + bool testnet = command_line::get_arg(vm, arg_testnet); + tools::password_container pwd_container; if (command_line::has_arg(vm, arg_password)) { @@ -378,12 +381,12 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) return false; } } - bool r = new_wallet(m_wallet_file, pwd_container.password(), m_recovery_key, m_restore_deterministic_wallet, m_non_deterministic); + bool r = new_wallet(m_wallet_file, pwd_container.password(), m_recovery_key, m_restore_deterministic_wallet, m_non_deterministic, testnet); CHECK_AND_ASSERT_MES(r, false, "account creation failed"); } else { - bool r = open_wallet(m_wallet_file, pwd_container.password()); + bool r = open_wallet(m_wallet_file, pwd_container.password(), testnet); CHECK_AND_ASSERT_MES(r, false, "could not open account"); } @@ -423,11 +426,11 @@ bool simple_wallet::try_connect_to_daemon() } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::new_wallet(const string &wallet_file, const std::string& password, const crypto::secret_key& recovery_key, bool recover, bool two_random) +bool simple_wallet::new_wallet(const string &wallet_file, const std::string& password, const crypto::secret_key& recovery_key, bool recover, bool two_random, bool testnet) { m_wallet_file = wallet_file; - m_wallet.reset(new tools::wallet2()); + m_wallet.reset(new tools::wallet2(testnet)); m_wallet->callback(this); crypto::secret_key recovery_val; @@ -471,10 +474,10 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas return true; } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::open_wallet(const string &wallet_file, const std::string& password) +bool simple_wallet::open_wallet(const string &wallet_file, const std::string& password, bool testnet) { m_wallet_file = wallet_file; - m_wallet.reset(new tools::wallet2()); + m_wallet.reset(new tools::wallet2(testnet)); m_wallet->callback(this); try @@ -1075,6 +1078,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_params, arg_restore_deterministic_wallet ); command_line::add_arg(desc_params, arg_non_deterministic ); command_line::add_arg(desc_params, arg_electrum_seed ); + command_line::add_arg(desc_params, arg_testnet); tools::wallet_rpc_server::init_options(desc_params); po::positional_options_description positional_options; @@ -1144,6 +1148,7 @@ int main(int argc, char* argv[]) return 1; } + bool testnet = command_line::get_arg(vm, arg_testnet); std::string wallet_file = command_line::get_arg(vm, arg_wallet_file); std::string wallet_password = command_line::get_arg(vm, arg_password); std::string daemon_address = command_line::get_arg(vm, arg_daemon_address); @@ -1156,7 +1161,7 @@ int main(int argc, char* argv[]) if (daemon_address.empty()) daemon_address = std::string("http://") + daemon_host + ":" + std::to_string(daemon_port); - tools::wallet2 wal; + tools::wallet2 wal(testnet); try { LOG_PRINT_L0("Loading wallet..."); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 41197b4bb..17affd564 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -66,8 +66,8 @@ namespace cryptonote bool run_console_handler(); - bool new_wallet(const std::string &wallet_file, const std::string& password, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false, bool two_random = false); - bool open_wallet(const std::string &wallet_file, const std::string& password); + bool new_wallet(const std::string &wallet_file, const std::string& password, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false, bool two_random = false, bool testnet = false); + bool open_wallet(const std::string &wallet_file, const std::string& password, bool testnet); bool close_wallet(); bool viewkey(const std::vector<std::string> &args = std::vector<std::string>()); |