aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-29 16:57:12 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-09-10 09:04:18 +0000
commit44439c32088dc684d686a392acf807f12ca0e0e9 (patch)
treebbf9e3da0fcf19c529061d540c26c2a0e6270e22 /src/simplewallet/simplewallet.cpp
parentblockchain_blackball: more optimizations (diff)
downloadmonero-44439c32088dc684d686a392acf807f12ca0e0e9.tar.xz
record blackballs as amount/offset, and add export ability
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp63
1 files changed, 40 insertions, 23 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index f5aeabded..e0e0c441a 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -1624,23 +1624,23 @@ bool simple_wallet::set_ring(const std::vector<std::string> &args)
bool simple_wallet::blackball(const std::vector<std::string> &args)
{
- crypto::public_key output;
+ uint64_t amount = std::numeric_limits<uint64_t>::max(), offset, num_offsets;
if (args.size() == 0)
{
- fail_msg_writer() << tr("usage: blackball <output_public_key> | <filename> [add]");
+ fail_msg_writer() << tr("usage: blackball <amount>/<offset> | <filename> [add]");
return true;
}
try
{
- if (epee::string_tools::hex_to_pod(args[0], output))
+ if (sscanf(args[0].c_str(), "%" PRIu64 "/%" PRIu64, &amount, &offset) == 2)
{
- m_wallet->blackball_output(output);
+ m_wallet->blackball_output(std::make_pair(amount, offset));
}
else if (epee::file_io_utils::is_file_exist(args[0]))
{
- std::vector<crypto::public_key> outputs;
- char str[65];
+ std::vector<std::pair<uint64_t, uint64_t>> outputs;
+ char str[256];
std::unique_ptr<FILE, tools::close_file> f(fopen(args[0].c_str(), "r"));
if (f)
@@ -1654,10 +1654,27 @@ bool simple_wallet::blackball(const std::vector<std::string> &args)
str[len - 1] = 0;
if (!str[0])
continue;
- outputs.push_back(crypto::public_key());
- if (!epee::string_tools::hex_to_pod(str, outputs.back()))
+ if (sscanf(str, "@%" PRIu64, &amount) == 1)
{
- fail_msg_writer() << tr("Invalid public key: ") << str;
+ continue;
+ }
+ if (amount == std::numeric_limits<uint64_t>::max())
+ {
+ fail_msg_writer() << tr("First line is not an amount");
+ return true;
+ }
+ if (sscanf(str, "%" PRIu64 "*%" PRIu64, &offset, &num_offsets) == 2 && num_offsets <= std::numeric_limits<uint64_t>::max() - offset)
+ {
+ while (num_offsets--)
+ outputs.push_back(std::make_pair(amount, offset++));
+ }
+ else if (sscanf(str, "%" PRIu64, &offset) == 1)
+ {
+ outputs.push_back(std::make_pair(amount, offset));
+ }
+ else
+ {
+ fail_msg_writer() << tr("Invalid output: ") << str;
return true;
}
}
@@ -1682,7 +1699,7 @@ bool simple_wallet::blackball(const std::vector<std::string> &args)
}
else
{
- fail_msg_writer() << tr("Invalid public key, and file doesn't exist");
+ fail_msg_writer() << tr("Invalid output key, and file doesn't exist");
return true;
}
}
@@ -1696,16 +1713,16 @@ bool simple_wallet::blackball(const std::vector<std::string> &args)
bool simple_wallet::unblackball(const std::vector<std::string> &args)
{
- crypto::public_key output;
+ std::pair<uint64_t, uint64_t> output;
if (args.size() != 1)
{
- fail_msg_writer() << tr("usage: unblackball <output_public_key>");
+ fail_msg_writer() << tr("usage: unblackball <amount>/<offset>");
return true;
}
- if (!epee::string_tools::hex_to_pod(args[0], output))
+ if (sscanf(args[0].c_str(), "%" PRIu64 "/%" PRIu64, &output.first, &output.second) != 2)
{
- fail_msg_writer() << tr("Invalid public key");
+ fail_msg_writer() << tr("Invalid output");
return true;
}
@@ -1723,25 +1740,25 @@ bool simple_wallet::unblackball(const std::vector<std::string> &args)
bool simple_wallet::blackballed(const std::vector<std::string> &args)
{
- crypto::public_key output;
+ std::pair<uint64_t, uint64_t> output;
if (args.size() != 1)
{
- fail_msg_writer() << tr("usage: blackballed <output_public_key>");
+ fail_msg_writer() << tr("usage: blackballed <amount>/<offset>");
return true;
}
- if (!epee::string_tools::hex_to_pod(args[0], output))
+ if (sscanf(args[0].c_str(), "%" PRIu64 "/%" PRIu64, &output.first, &output.second) != 2)
{
- fail_msg_writer() << tr("Invalid public key");
+ fail_msg_writer() << tr("Invalid output");
return true;
}
try
{
if (m_wallet->is_output_blackballed(output))
- message_writer() << tr("Blackballed: ") << output;
+ message_writer() << tr("Blackballed: ") << output.first << "/" << output.second;
else
- message_writer() << tr("not blackballed: ") << output;
+ message_writer() << tr("not blackballed: ") << output.first << "/" << output.second;
}
catch (const std::exception &e)
{
@@ -2554,15 +2571,15 @@ simple_wallet::simple_wallet()
tr("Save known rings to the shared rings database"));
m_cmd_binder.set_handler("blackball",
boost::bind(&simple_wallet::blackball, this, _1),
- tr("blackball <output public key> | <filename> [add]"),
+ tr("blackball <amount>/<offset> | <filename> [add]"),
tr("Blackball output(s) so they never get selected as fake outputs in a ring"));
m_cmd_binder.set_handler("unblackball",
boost::bind(&simple_wallet::unblackball, this, _1),
- tr("unblackball <output public key>"),
+ tr("unblackball <amount>/<offset>"),
tr("Unblackballs an output so it may get selected as a fake output in a ring"));
m_cmd_binder.set_handler("blackballed",
boost::bind(&simple_wallet::blackballed, this, _1),
- tr("blackballed <output public key>"),
+ tr("blackballed <amount>/<offset>"),
tr("Checks whether an output is blackballed"));
m_cmd_binder.set_handler("version",
boost::bind(&simple_wallet::version, this, _1),