From 8be5fea1dedfa844afca365d11136e7cc95d5e31 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 2 Jul 2019 19:41:41 +0000 Subject: simplewallet: optional all flag to export_outputs/export_key_images --- src/simplewallet/simplewallet.cpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'src/simplewallet') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 02a099811..359b8824e 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -199,11 +199,11 @@ namespace const char* USAGE_SET_DESCRIPTION("set_description [free text note]"); const char* USAGE_SIGN("sign "); const char* USAGE_VERIFY("verify
"); - const char* USAGE_EXPORT_KEY_IMAGES("export_key_images "); + const char* USAGE_EXPORT_KEY_IMAGES("export_key_images [all] "); const char* USAGE_IMPORT_KEY_IMAGES("import_key_images "); const char* USAGE_HW_KEY_IMAGES_SYNC("hw_key_images_sync"); const char* USAGE_HW_RECONNECT("hw_reconnect"); - const char* USAGE_EXPORT_OUTPUTS("export_outputs "); + const char* USAGE_EXPORT_OUTPUTS("export_outputs [all] "); const char* USAGE_IMPORT_OUTPUTS("import_outputs "); const char* USAGE_SHOW_TRANSFER("show_transfer "); const char* USAGE_MAKE_MULTISIG("make_multisig [...]"); @@ -8937,21 +8937,31 @@ bool simple_wallet::verify(const std::vector &args) return true; } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::export_key_images(const std::vector &args) +bool simple_wallet::export_key_images(const std::vector &args_) { if (m_wallet->key_on_device()) { fail_msg_writer() << tr("command not supported by HW wallet"); return true; } - if (args.size() != 1) + auto args = args_; + + if (m_wallet->watch_only()) { - PRINT_USAGE(USAGE_EXPORT_KEY_IMAGES); + fail_msg_writer() << tr("wallet is watch-only and cannot export key images"); return true; } - if (m_wallet->watch_only()) + + bool all = false; + if (args.size() >= 2 && args[0] == "all") { - fail_msg_writer() << tr("wallet is watch-only and cannot export key images"); + all = true; + args.erase(args.begin()); + } + + if (args.size() != 1) + { + PRINT_USAGE(USAGE_EXPORT_KEY_IMAGES); return true; } @@ -8963,7 +8973,7 @@ bool simple_wallet::export_key_images(const std::vector &args) try { - if (!m_wallet->export_key_images(filename)) + if (!m_wallet->export_key_images(filename, all)) { fail_msg_writer() << tr("failed to save file ") << filename; return true; @@ -9088,13 +9098,22 @@ bool simple_wallet::hw_reconnect(const std::vector &args) return true; } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::export_outputs(const std::vector &args) +bool simple_wallet::export_outputs(const std::vector &args_) { if (m_wallet->key_on_device()) { fail_msg_writer() << tr("command not supported by HW wallet"); return true; } + auto args = args_; + + bool all = false; + if (args.size() >= 2 && args[0] == "all") + { + all = true; + args.erase(args.begin()); + } + if (args.size() != 1) { PRINT_USAGE(USAGE_EXPORT_OUTPUTS); @@ -9109,7 +9128,7 @@ bool simple_wallet::export_outputs(const std::vector &args) try { - std::string data = m_wallet->export_outputs_to_str(); + std::string data = m_wallet->export_outputs_to_str(all); bool r = epee::file_io_utils::save_string_to_file(filename, data); if (!r) { -- cgit v1.2.3