aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-09-14 12:45:18 +0200
committerRiccardo Spagni <ric@spagni.net>2018-09-14 12:45:18 +0200
commitc74d9057f89455691140757f430e952d1951435a (patch)
tree24bc50c3279f085fd6d6f1ab92f010e842b60750 /src/simplewallet
parentMerge pull request #4254 (diff)
parentblockchain_blackball: add --force-chain-reaction-pass flag (diff)
downloadmonero-c74d9057f89455691140757f430e952d1951435a.tar.xz
Merge pull request #4260
a54dbaee blockchain_blackball: add --force-chain-reaction-pass flag (moneromooo-monero) 44439c32 record blackballs as amount/offset, and add export ability (moneromooo-monero) 4bce935b blockchain_blackball: more optimizations (moneromooo-monero) b66ba783 blockchain_blackball: do not process duplicate blockchains parts (moneromooo-monero) 639a3c01 blockchain_blackball: make it clear secondary passes are not incremental (moneromooo-monero) eb8a51be blockchain_blackball: detect spent outputs by partial ring reuse (moneromooo-monero) d6d276c6 blockchain_blackball: fix chain reaction phase in incremental mode (moneromooo-monero) 2b2a681b blockchain_blackball: avoid false positives for different amounts (moneromooo-monero) 80e4fef3 blockchain_blackball: set transaction looping txn to read only (moneromooo-monero) 4801d6b5 blockchain_blackball: add stats (moneromooo-monero) 846190fd blockchain_blackball: support pre-v2 databases (moneromooo-monero) daa6cc7d blockchain_blackball: use LMDB for the cache (moneromooo-monero) 50cb370d ringdb: allow blackballing many outputs at once (moneromooo-monero)
Diffstat (limited to 'src/simplewallet')
-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 fc6c4ab43..0d351e23e 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -1627,23 +1627,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)
@@ -1657,10 +1657,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;
}
}
@@ -1685,7 +1702,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;
}
}
@@ -1699,16 +1716,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;
}
@@ -1726,25 +1743,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)
{
@@ -2559,15 +2576,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),