aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authorHoria Mihai David <david.horiamihai@gmail.com>2021-01-11 22:20:12 +0100
committerhMihaiDavid <24855110+hMihaiDavid@users.noreply.github.com>2021-02-17 20:25:55 +0100
commit186271e5d1633964a37220e3b6c1aebb4f691fd9 (patch)
treedab728ded4b39ee6f85909c2ba7d21b75525eb63 /src/simplewallet/simplewallet.cpp
parentMerge pull request #7285 (diff)
downloadmonero-186271e5d1633964a37220e3b6c1aebb4f691fd9.tar.xz
monero-wallet-cli: Added command scan_tx
To implement this feature, the wallet2::scan_tx API was implemented.
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 0635520c6..dad4aab6c 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -282,6 +282,7 @@ namespace
const char* USAGE_VERSION("version");
const char* USAGE_HELP("help [<command> | all]");
const char* USAGE_APROPOS("apropos <keyword> [<keyword> ...]");
+ const char* USAGE_SCAN_TX("scan_tx <txid> [<txid> ...]");
std::string input_line(const std::string& prompt, bool yesno = false)
{
@@ -3214,6 +3215,45 @@ bool simple_wallet::apropos(const std::vector<std::string> &args)
return true;
}
+bool simple_wallet::scan_tx(const std::vector<std::string> &args)
+{
+ if (args.empty())
+ {
+ PRINT_USAGE(USAGE_SCAN_TX);
+ return true;
+ }
+
+ // Parse and dedup args
+ std::unordered_set<crypto::hash> txids;
+ for (const auto &s : args) {
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(s, txid)) {
+ fail_msg_writer() << tr("Invalid txid specified: ") << s;
+ return true;
+ }
+ txids.insert(txid);
+ }
+ std::vector<crypto::hash> txids_v(txids.begin(), txids.end());
+
+ if (!m_wallet->is_trusted_daemon()) {
+ message_writer(console_color_red, true) << tr("WARNING: this operation may reveal the txids to the remote node and affect your privacy");
+ if (!command_line::is_yes(input_line("Do you want to continue?", true))) {
+ message_writer() << tr("You have canceled the operation");
+ return true;
+ }
+ }
+
+ LOCK_IDLE_SCOPE();
+ m_in_manual_refresh.store(true);
+ try {
+ m_wallet->scan_tx(txids_v);
+ } catch (const std::exception &e) {
+ fail_msg_writer() << e.what();
+ }
+ m_in_manual_refresh.store(false);
+ return true;
+}
+
simple_wallet::simple_wallet()
: m_allow_mismatched_daemon_version(false)
, m_refresh_progress_reporter(*this)
@@ -3763,6 +3803,10 @@ simple_wallet::simple_wallet()
boost::bind(&simple_wallet::on_command, this, &simple_wallet::apropos, _1),
tr(USAGE_APROPOS),
tr("Search all command descriptions for keyword(s)"));
+ m_cmd_binder.set_handler("scan_tx",
+ boost::bind(&simple_wallet::on_command, this, &simple_wallet::scan_tx, _1),
+ tr(USAGE_SCAN_TX),
+ tr("Scan the transactions given by <txid>(s), processing them and looking for outputs"));
m_cmd_binder.set_unknown_command_handler(boost::bind(&simple_wallet::on_command, this, &simple_wallet::on_unknown_command, _1));
m_cmd_binder.set_empty_command_handler(boost::bind(&simple_wallet::on_empty_command, this));
m_cmd_binder.set_cancel_handler(boost::bind(&simple_wallet::on_cancelled_command, this));
@@ -11648,4 +11692,3 @@ bool simple_wallet::mms(const std::vector<std::string> &args)
return true;
}
// End MMS ------------------------------------------------------------------------------------------------
-