From 0be5b2ee78efaa242757ca8f998a091f8930788d Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 2 Apr 2019 14:03:25 +0000 Subject: simplewallet: new unset_ring command Useful when debugging, though not much for users --- src/simplewallet/simplewallet.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 8974bd1e0..23122e1bb 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -235,6 +235,7 @@ namespace const char* USAGE_MMS_AUTO_CONFIG("mms auto_config "); const char* USAGE_PRINT_RING("print_ring | "); const char* USAGE_SET_RING("set_ring | ( absolute|relative [...] )"); + const char* USAGE_UNSET_RING("unset_ring | ( [...] )"); const char* USAGE_SAVE_KNOWN_RINGS("save_known_rings"); const char* USAGE_MARK_OUTPUT_SPENT("mark_output_spent / | [add]"); const char* USAGE_MARK_OUTPUT_UNSPENT("mark_output_unspent /"); @@ -1870,6 +1871,38 @@ bool simple_wallet::set_ring(const std::vector &args) return true; } +bool simple_wallet::unset_ring(const std::vector &args) +{ + crypto::hash txid; + std::vector key_images; + + if (args.size() < 1) + { + PRINT_USAGE(USAGE_UNSET_RING); + return true; + } + + key_images.resize(args.size()); + for (size_t i = 0; i < args.size(); ++i) + { + if (!epee::string_tools::hex_to_pod(args[i], key_images[i])) + { + fail_msg_writer() << tr("Invalid key image or txid"); + return true; + } + } + static_assert(sizeof(crypto::hash) == sizeof(crypto::key_image), "hash and key_image must have the same size"); + memcpy(&txid, &key_images[0], sizeof(txid)); + + if (!m_wallet->unset_ring(key_images) && !m_wallet->unset_ring(txid)) + { + fail_msg_writer() << tr("failed to unset ring"); + return true; + } + + return true; +} + bool simple_wallet::blackball(const std::vector &args) { uint64_t amount = std::numeric_limits::max(), offset, num_offsets; @@ -3069,6 +3102,10 @@ simple_wallet::simple_wallet() boost::bind(&simple_wallet::set_ring, this, _1), tr(USAGE_SET_RING), tr("Set the ring used for a given key image, so it can be reused in a fork")); + m_cmd_binder.set_handler("unset_ring", + boost::bind(&simple_wallet::unset_ring, this, _1), + tr(USAGE_UNSET_RING), + tr("Unsets the ring used for a given key image or transaction")); m_cmd_binder.set_handler("save_known_rings", boost::bind(&simple_wallet::save_known_rings, this, _1), tr(USAGE_SAVE_KNOWN_RINGS), @@ -5297,7 +5334,7 @@ bool simple_wallet::print_ring_members(const std::vector absolute_offsets = cryptonote::relative_output_offsets_to_absolute(in_key.key_offsets); // get block heights from which those ring member keys originated -- cgit v1.2.3