wallet: encrypt (un)signed tx, also optionally save unencrypted raw tx hexstr

This commit is contained in:
stoffu
2017-09-30 13:28:17 +09:00
parent 86e9de588c
commit d74336d5c9
3 changed files with 129 additions and 25 deletions

View File

@@ -3432,12 +3432,18 @@ 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"))
{
fail_msg_writer() << tr("usage: sign_transfer [export]");
return true;
}
if (m_wallet->ask_password() && !get_and_verify_password()) { return true; }
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); });
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);
if (!r)
{
fail_msg_writer() << tr("Failed to sign transaction");
@@ -3458,6 +3464,17 @@ bool simple_wallet::sign_transfer(const std::vector<std::string> &args_)
txids_as_text += epee::string_tools::pod_to_hex(get_transaction_hash(t.tx));
}
success_msg_writer(true) << tr("Transaction successfully signed to file ") << "signed_monero_tx" << ", txid " << txids_as_text;
if (export_raw)
{
std::string rawfiles_as_text;
for (size_t i = 0; i < ptx.size(); ++i)
{
if (i > 0)
rawfiles_as_text += ", ";
rawfiles_as_text += "signed_monero_tx_raw" + (ptx.size() == 1 ? "" : ("_" + std::to_string(i)));
}
success_msg_writer(true) << tr("Transaction raw hex data exported to ") << rawfiles_as_text;
}
return true;
}
//----------------------------------------------------------------------------------------------------