mirror of
https://github.com/monero-project/monero.git
synced 2025-08-16 23:00:24 -04:00
Merge pull request #5388
0be5b2ee
simplewallet: new unset_ring command (moneromooo-monero)
This commit is contained in:
commit
5db72d12b4
6 changed files with 100 additions and 12 deletions
|
@ -235,6 +235,7 @@ namespace
|
|||
const char* USAGE_MMS_AUTO_CONFIG("mms auto_config <auto_config_token>");
|
||||
const char* USAGE_PRINT_RING("print_ring <key_image> | <txid>");
|
||||
const char* USAGE_SET_RING("set_ring <filename> | ( <key_image> absolute|relative <index> [<index>...] )");
|
||||
const char* USAGE_UNSET_RING("unset_ring <txid> | ( <key_image> [<key_image>...] )");
|
||||
const char* USAGE_SAVE_KNOWN_RINGS("save_known_rings");
|
||||
const char* USAGE_MARK_OUTPUT_SPENT("mark_output_spent <amount>/<offset> | <filename> [add]");
|
||||
const char* USAGE_MARK_OUTPUT_UNSPENT("mark_output_unspent <amount>/<offset>");
|
||||
|
@ -1871,6 +1872,38 @@ bool simple_wallet::set_ring(const std::vector<std::string> &args)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simple_wallet::unset_ring(const std::vector<std::string> &args)
|
||||
{
|
||||
crypto::hash txid;
|
||||
std::vector<crypto::key_image> 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<std::string> &args)
|
||||
{
|
||||
uint64_t amount = std::numeric_limits<uint64_t>::max(), offset, num_offsets;
|
||||
|
@ -3102,6 +3135,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),
|
||||
|
@ -5462,7 +5499,7 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
|
|||
}
|
||||
const cryptonote::tx_source_entry& source = *sptr;
|
||||
|
||||
ostr << boost::format(tr("\nInput %llu/%llu: amount=%s")) % (i + 1) % tx.vin.size() % print_money(source.amount);
|
||||
ostr << boost::format(tr("\nInput %llu/%llu (%s): amount=%s")) % (i + 1) % tx.vin.size() % epee::string_tools::pod_to_hex(in_key.k_image) % print_money(source.amount);
|
||||
// convert relative offsets of ring member keys into absolute offsets (indices) associated with the amount
|
||||
std::vector<uint64_t> absolute_offsets = cryptonote::relative_output_offsets_to_absolute(in_key.key_offsets);
|
||||
// get block heights from which those ring member keys originated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue