aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 6491955c6..3668df7b9 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -62,7 +62,6 @@
#include "ringct/rctSigs.h"
#include "multisig/multisig.h"
#include "wallet/wallet_args.h"
-#include "device/device.hpp"
#include <stdexcept>
#ifdef WIN32
@@ -134,6 +133,7 @@ namespace
const command_line::arg_descriptor<bool> arg_allow_mismatched_daemon_version = {"allow-mismatched-daemon-version", sw::tr("Allow communicating with a daemon that uses a different RPC version"), false};
const command_line::arg_descriptor<uint64_t> arg_restore_height = {"restore-height", sw::tr("Restore from specific blockchain height"), 0};
const command_line::arg_descriptor<bool> arg_do_not_relay = {"do-not-relay", sw::tr("The newly created transaction will not be relayed to the monero network"), false};
+ const command_line::arg_descriptor<bool> arg_create_address_file = {"create-address-file", sw::tr("Create an address file for new wallets"), false};
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
@@ -2848,10 +2848,12 @@ bool simple_wallet::new_wallet(const boost::program_options::variables_map& vm,
m_wallet->set_seed_language(mnemonic_language);
+ bool create_address_file = command_line::get_arg(vm, arg_create_address_file);
+
crypto::secret_key recovery_val;
try
{
- recovery_val = m_wallet->generate(m_wallet_file, std::move(rc.second).password(), recovery_key, recover, two_random);
+ recovery_val = m_wallet->generate(m_wallet_file, std::move(rc.second).password(), recovery_key, recover, two_random, create_address_file);
message_writer(console_color_white, true) << tr("Generated new wallet: ")
<< m_wallet->get_account().get_public_address_str(m_wallet->nettype());
std::cout << tr("View key: ") << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << ENDL;
@@ -2900,15 +2902,17 @@ bool simple_wallet::new_wallet(const boost::program_options::variables_map& vm,
if (m_restore_height)
m_wallet->set_refresh_from_block_height(m_restore_height);
+ bool create_address_file = command_line::get_arg(vm, arg_create_address_file);
+
try
{
if (spendkey)
{
- m_wallet->generate(m_wallet_file, std::move(rc.second).password(), address, *spendkey, viewkey);
+ m_wallet->generate(m_wallet_file, std::move(rc.second).password(), address, *spendkey, viewkey, create_address_file);
}
else
{
- m_wallet->generate(m_wallet_file, std::move(rc.second).password(), address, viewkey);
+ m_wallet->generate(m_wallet_file, std::move(rc.second).password(), address, viewkey, create_address_file);
}
message_writer(console_color_white, true) << tr("Generated new wallet: ")
<< m_wallet->get_account().get_public_address_str(m_wallet->nettype());
@@ -2971,9 +2975,11 @@ bool simple_wallet::new_wallet(const boost::program_options::variables_map& vm,
m_wallet->set_seed_language(mnemonic_language);
+ bool create_address_file = command_line::get_arg(vm, arg_create_address_file);
+
try
{
- m_wallet->generate(m_wallet_file, std::move(rc.second).password(), multisig_keys);
+ m_wallet->generate(m_wallet_file, std::move(rc.second).password(), multisig_keys, create_address_file);
bool ready;
uint32_t threshold, total;
if (!m_wallet->multisig(&ready, &threshold, &total) || !ready)
@@ -3143,7 +3149,17 @@ bool simple_wallet::save_watch_only(const std::vector<std::string> &args/* = std
return true;
}
- m_wallet->write_watch_only_wallet(m_wallet_file, pwd_container->password());
+ try
+ {
+ std::string new_keys_filename;
+ m_wallet->write_watch_only_wallet(m_wallet_file, pwd_container->password(), new_keys_filename);
+ success_msg_writer() << tr("Watch only wallet saved as: ") << new_keys_filename;
+ }
+ catch (const std::exception &e)
+ {
+ fail_msg_writer() << tr("Failed to save watch only wallet: ") << e.what();
+ return true;
+ }
return true;
}
@@ -6978,6 +6994,7 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_params, arg_allow_mismatched_daemon_version);
command_line::add_arg(desc_params, arg_restore_height);
command_line::add_arg(desc_params, arg_do_not_relay);
+ command_line::add_arg(desc_params, arg_create_address_file);
po::positional_options_description positional_options;
positional_options.add(arg_command.name, -1);