aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-19 20:59:44 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-19 21:11:48 +0100
commit6c995710d8cdc8dbbb3da2d11dc8dfe335074ec9 (patch)
treead354dd1a0f409e9acfa8959d4faa382d4f94bd1 /src/simplewallet
parentMerge pull request #379 (diff)
downloadmonero-6c995710d8cdc8dbbb3da2d11dc8dfe335074ec9.tar.xz
make tx keys available to the user
They are also stored in the cache file, to be retrieved using a new get_tx_key command.
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp32
-rw-r--r--src/simplewallet/simplewallet.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 0c91d9787..ff60ea38e 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -365,6 +365,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Get deterministic seed"));
m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("available options: seed language - Set wallet seed langage; always-confirm-transfers <1|0> - whether to confirm unsplit txes"));
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
+ m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given tx"));
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), tr("Show this help"));
}
//----------------------------------------------------------------------------------------------------
@@ -1724,6 +1725,37 @@ bool simple_wallet::sweep_dust(const std::vector<std::string> &args_)
return true;
}
//----------------------------------------------------------------------------------------------------
+bool simple_wallet::get_tx_key(const std::vector<std::string> &args_)
+{
+ std::vector<std::string> local_args = args_;
+
+ if(local_args.size() != 1) {
+ fail_msg_writer() << tr("Usage: get_tx_key <txid>");
+ return true;
+ }
+
+ cryptonote::blobdata txid_data;
+ if(!epee::string_tools::parse_hexstr_to_binbuff(local_args.front(), txid_data))
+ {
+ fail_msg_writer() << tr("Failed to parse txid");
+ return false;
+ }
+ crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
+
+ crypto::secret_key tx_key;
+ bool r = m_wallet->get_tx_key(txid, tx_key);
+ if (r)
+ {
+ success_msg_writer() << tr("tx key: ") << tx_key;
+ return true;
+ }
+ else
+ {
+ fail_msg_writer() << tr("No tx key found for this txid");
+ return true;
+ }
+}
+//----------------------------------------------------------------------------------------------------
bool simple_wallet::run()
{
std::string addr_start = m_wallet->get_account().get_public_address_str(m_wallet->testnet()).substr(0, 6);
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index 8aca93210..7db56cdec 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -122,6 +122,7 @@ namespace cryptonote
bool set_variable(const std::vector<std::string> &args);
bool rescan_spent(const std::vector<std::string> &args);
bool set_log(const std::vector<std::string> &args);
+ bool get_tx_key(const std::vector<std::string> &args);
uint64_t get_daemon_blockchain_height(std::string& err);
bool try_connect_to_daemon();