aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authorSteff Richards <steff.richards.the.third@gmail.com>2020-12-31 16:54:01 +0100
committerSteff Richards <steff.richards.the.third@gmail.com>2020-12-31 16:54:01 +0100
commit021a28137d6a8232bf358b6e153d0061ae66e668 (patch)
tree4746e3d40a1a84de719ade73a5addc7ba1c45377 /src/simplewallet/simplewallet.cpp
parentMerge pull request #7221 (diff)
downloadmonero-021a28137d6a8232bf358b6e153d0061ae66e668.tar.xz
simplewallet: Add input file parameter to sign_transfer
Diffstat (limited to '')
-rw-r--r--src/simplewallet/simplewallet.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 0635520c6..052782ad5 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -195,7 +195,7 @@ namespace
const char* USAGE_SWEEP_BELOW("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id (obsolete)>]");
const char* USAGE_SWEEP_SINGLE("sweep_single [<priority>] [<ring_size>] [outputs=<N>] <key_image> <address> [<payment_id (obsolete)>]");
const char* USAGE_DONATE("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id (obsolete)>]");
- const char* USAGE_SIGN_TRANSFER("sign_transfer [export_raw]");
+ const char* USAGE_SIGN_TRANSFER("sign_transfer [export_raw] [<filename>]");
const char* USAGE_SET_LOG("set_log <level>|{+,-,}<categories>");
const char* USAGE_ACCOUNT("account\n"
" account new <label text with white spaces allowed>\n"
@@ -3301,7 +3301,8 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("sign_transfer",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::sign_transfer, _1),
tr(USAGE_SIGN_TRANSFER),
- tr("Sign a transaction from a file. If the parameter \"export_raw\" is specified, transaction raw hex data suitable for the daemon RPC /sendrawtransaction is exported."));
+ tr("Sign a transaction from a file. If the parameter \"export_raw\" is specified, transaction raw hex data suitable for the daemon RPC /sendrawtransaction is exported.\n"
+ "Use the parameter <filename> to specify the file to read from. If not specified, the default \"unsigned_monero_tx\" will be used."));
m_cmd_binder.set_handler("submit_transfer",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::submit_transfer, _1),
tr("Submit a signed transaction from a file."));
@@ -7886,19 +7887,33 @@ bool simple_wallet::sign_transfer(const std::vector<std::string> &args_)
fail_msg_writer() << tr("This is a watch only wallet");
return true;
}
- if (args_.size() > 1 || (args_.size() == 1 && args_[0] != "export_raw"))
+
+ bool export_raw = false;
+ std::string unsigned_filename = "unsigned_monero_tx";
+ if (args_.size() > 2 || (args_.size() == 2 && args_[0] != "export_raw"))
{
PRINT_USAGE(USAGE_SIGN_TRANSFER);
return true;
}
+ else if (args_.size() == 2)
+ {
+ export_raw = true;
+ unsigned_filename = args_[1];
+ }
+ else if (args_.size() == 1)
+ {
+ if (args_[0] == "export_raw")
+ export_raw = true;
+ else
+ unsigned_filename = args_[0];
+ }
SCOPED_WALLET_UNLOCK();
- const bool export_raw = args_.size() == 1;
std::vector<tools::wallet2::pending_tx> ptx;
try
{
- bool r = m_wallet->sign_tx("unsigned_monero_tx", "signed_monero_tx", ptx, [&](const tools::wallet2::unsigned_tx_set &tx){ return accept_loaded_tx(tx); }, export_raw);
+ bool r = m_wallet->sign_tx(unsigned_filename, "signed_monero_tx", ptx, [&](const tools::wallet2::unsigned_tx_set &tx){ return accept_loaded_tx(tx); }, export_raw);
if (!r)
{
fail_msg_writer() << tr("Failed to sign transaction");