aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-24 21:50:45 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-24 21:52:34 +0100
commite20a3ae011dcc8724d8131ba245141a6ef2c16e3 (patch)
tree6e733402f7abb5512b9cb51fbde33f1b330c090f
parentMerge pull request #386 (diff)
downloadmonero-e20a3ae011dcc8724d8131ba245141a6ef2c16e3.tar.xz
simplewallet: add a store-tx-keys option to set
To enable storing tx keys in the (now encrypted) wallet cache.
-rw-r--r--src/simplewallet/simplewallet.cpp46
-rw-r--r--src/simplewallet/simplewallet.h1
2 files changed, 46 insertions, 1 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index ff60ea38e..9ff0fa264 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -334,6 +334,35 @@ bool simple_wallet::set_always_confirm_transfers(const std::vector<std::string>
return true;
}
+bool simple_wallet::set_store_tx_keys(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
+{
+ bool success = false;
+ if (m_wallet->watch_only())
+ {
+ fail_msg_writer() << tr("This wallet is watch-only and cannot transfer.");
+ return true;
+ }
+ tools::password_container pwd_container;
+ success = pwd_container.read_password();
+ if (!success)
+ {
+ fail_msg_writer() << tr("failed to read wallet password");
+ return true;
+ }
+
+ /* verify password before using so user doesn't accidentally set a new password for rewritten wallet */
+ success = m_wallet->verify_password(pwd_container.password());
+ if (!success)
+ {
+ fail_msg_writer() << tr("invalid password");
+ return true;
+ }
+
+ m_wallet->store_tx_keys(is_it_true(args[1]));
+ m_wallet->rewrite(m_wallet_file, pwd_container.password());
+ return true;
+}
+
bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
success_msg_writer() << get_commands_str();
@@ -363,7 +392,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Get viewkey"));
m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Get spendkey"));
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("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; store-tx-keys <1|0> - whether to store per-tx private keys for future reference"));
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"));
@@ -408,6 +437,21 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
return true;
}
}
+ else if (args[0] == "store-tx-keys")
+ {
+ if (args.size() <= 1)
+ {
+ fail_msg_writer() << tr("set store-tx-keys: needs an argument (0 or 1)");
+ return true;
+ }
+ else
+ {
+ std::vector<std::string> local_args = args;
+ local_args.erase(local_args.begin(), local_args.begin()+2);
+ set_store_tx_keys(local_args);
+ return true;
+ }
+ }
}
fail_msg_writer() << tr("set: unrecognized argument(s)");
return true;
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index 7db56cdec..d8841f2d8 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -99,6 +99,7 @@ namespace cryptonote
*/
bool seed_set_language(const std::vector<std::string> &args = std::vector<std::string>());
bool set_always_confirm_transfers(const std::vector<std::string> &args = std::vector<std::string>());
+ bool set_store_tx_keys(const std::vector<std::string> &args = std::vector<std::string>());
bool help(const std::vector<std::string> &args = std::vector<std::string>());
bool start_mining(const std::vector<std::string> &args);
bool stop_mining(const std::vector<std::string> &args);