mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 09:24:47 +00:00
Merge pull request #5722
8be5fea
simplewallet: optional all flag to export_outputs/export_key_images (moneromooo-monero)
This commit is contained in:
commit
65e937168e
3 changed files with 33 additions and 14 deletions
|
@ -201,11 +201,11 @@ namespace
|
||||||
const char* USAGE_SET_DESCRIPTION("set_description [free text note]");
|
const char* USAGE_SET_DESCRIPTION("set_description [free text note]");
|
||||||
const char* USAGE_SIGN("sign <filename>");
|
const char* USAGE_SIGN("sign <filename>");
|
||||||
const char* USAGE_VERIFY("verify <filename> <address> <signature>");
|
const char* USAGE_VERIFY("verify <filename> <address> <signature>");
|
||||||
const char* USAGE_EXPORT_KEY_IMAGES("export_key_images <filename>");
|
const char* USAGE_EXPORT_KEY_IMAGES("export_key_images [all] <filename>");
|
||||||
const char* USAGE_IMPORT_KEY_IMAGES("import_key_images <filename>");
|
const char* USAGE_IMPORT_KEY_IMAGES("import_key_images <filename>");
|
||||||
const char* USAGE_HW_KEY_IMAGES_SYNC("hw_key_images_sync");
|
const char* USAGE_HW_KEY_IMAGES_SYNC("hw_key_images_sync");
|
||||||
const char* USAGE_HW_RECONNECT("hw_reconnect");
|
const char* USAGE_HW_RECONNECT("hw_reconnect");
|
||||||
const char* USAGE_EXPORT_OUTPUTS("export_outputs <filename>");
|
const char* USAGE_EXPORT_OUTPUTS("export_outputs [all] <filename>");
|
||||||
const char* USAGE_IMPORT_OUTPUTS("import_outputs <filename>");
|
const char* USAGE_IMPORT_OUTPUTS("import_outputs <filename>");
|
||||||
const char* USAGE_SHOW_TRANSFER("show_transfer <txid>");
|
const char* USAGE_SHOW_TRANSFER("show_transfer <txid>");
|
||||||
const char* USAGE_MAKE_MULTISIG("make_multisig <threshold> <string1> [<string>...]");
|
const char* USAGE_MAKE_MULTISIG("make_multisig <threshold> <string1> [<string>...]");
|
||||||
|
@ -9044,24 +9044,34 @@ bool simple_wallet::verify(const std::vector<std::string> &args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool simple_wallet::export_key_images(const std::vector<std::string> &args)
|
bool simple_wallet::export_key_images(const std::vector<std::string> &args_)
|
||||||
{
|
{
|
||||||
if (m_wallet->key_on_device())
|
if (m_wallet->key_on_device())
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("command not supported by HW wallet");
|
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.size() != 1)
|
auto args = args_;
|
||||||
{
|
|
||||||
PRINT_USAGE(USAGE_EXPORT_KEY_IMAGES);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (m_wallet->watch_only())
|
if (m_wallet->watch_only())
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("wallet is watch-only and cannot export key images");
|
fail_msg_writer() << tr("wallet is watch-only and cannot export key images");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool all = false;
|
||||||
|
if (args.size() >= 2 && args[0] == "all")
|
||||||
|
{
|
||||||
|
all = true;
|
||||||
|
args.erase(args.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size() != 1)
|
||||||
|
{
|
||||||
|
PRINT_USAGE(USAGE_EXPORT_KEY_IMAGES);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string filename = args[0];
|
std::string filename = args[0];
|
||||||
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
|
if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename))
|
||||||
return true;
|
return true;
|
||||||
|
@ -9070,7 +9080,7 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args)
|
||||||
|
|
||||||
try
|
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;
|
fail_msg_writer() << tr("failed to save file ") << filename;
|
||||||
return true;
|
return true;
|
||||||
|
@ -9195,13 +9205,22 @@ bool simple_wallet::hw_reconnect(const std::vector<std::string> &args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool simple_wallet::export_outputs(const std::vector<std::string> &args)
|
bool simple_wallet::export_outputs(const std::vector<std::string> &args_)
|
||||||
{
|
{
|
||||||
if (m_wallet->key_on_device())
|
if (m_wallet->key_on_device())
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("command not supported by HW wallet");
|
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||||
return true;
|
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)
|
if (args.size() != 1)
|
||||||
{
|
{
|
||||||
PRINT_USAGE(USAGE_EXPORT_OUTPUTS);
|
PRINT_USAGE(USAGE_EXPORT_OUTPUTS);
|
||||||
|
@ -9216,7 +9235,7 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args)
|
||||||
|
|
||||||
try
|
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);
|
bool r = epee::file_io_utils::save_string_to_file(filename, data);
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11607,10 +11607,10 @@ crypto::public_key wallet2::get_tx_pub_key_from_received_outs(const tools::walle
|
||||||
return tx_pub_key;
|
return tx_pub_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wallet2::export_key_images(const std::string &filename) const
|
bool wallet2::export_key_images(const std::string &filename, bool all) const
|
||||||
{
|
{
|
||||||
PERF_TIMER(export_key_images);
|
PERF_TIMER(export_key_images);
|
||||||
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> ski = export_key_images();
|
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> ski = export_key_images(all);
|
||||||
std::string magic(KEY_IMAGE_EXPORT_FILE_MAGIC, strlen(KEY_IMAGE_EXPORT_FILE_MAGIC));
|
std::string magic(KEY_IMAGE_EXPORT_FILE_MAGIC, strlen(KEY_IMAGE_EXPORT_FILE_MAGIC));
|
||||||
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
||||||
const uint32_t offset = ski.first;
|
const uint32_t offset = ski.first;
|
||||||
|
|
|
@ -1175,7 +1175,7 @@ private:
|
||||||
void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
|
void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
|
||||||
std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
|
std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
|
||||||
void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
|
void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
|
||||||
bool export_key_images(const std::string &filename) const;
|
bool export_key_images(const std::string &filename, bool all = false) const;
|
||||||
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const;
|
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const;
|
||||||
uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
|
uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
|
||||||
uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
|
uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
|
||||||
|
|
Loading…
Reference in a new issue