mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
Merge pull request #7242
021a281
simplewallet: Add input file parameter to sign_transfer (Steff Richards)
This commit is contained in:
commit
7439d891bf
@ -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."));
|
||||
@ -7891,19 +7892,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");
|
||||
|
Loading…
Reference in New Issue
Block a user