diff options
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 6af0de9f9..8ceb583be 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -785,6 +785,7 @@ bool simple_wallet::show_blockchain_height(const std::vector<std::string>& args) fail_msg_writer() << "failed to get blockchain height: " << err; return true; } + //---------------------------------------------------------------------------------------------------- bool simple_wallet::transfer(const std::vector<std::string> &args_) { @@ -851,9 +852,38 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_) try { - cryptonote::transaction tx; - m_wallet->transfer(dsts, fake_outs_count, 0, DEFAULT_FEE, extra, tx); - success_msg_writer(true) << "Money successfully sent, transaction " << get_transaction_hash(tx); + // figure out what tx will be necessary + auto ptx_vector = m_wallet->create_transactions(dsts, fake_outs_count, 0 /* unlock_time */, DEFAULT_FEE, extra); + + // if more than one tx necessary, prompt user to confirm + if (ptx_vector.size() > 1) + { + std::string prompt_str = "Your transaction needs to be split into "; + prompt_str += std::to_string(ptx_vector.size()); + prompt_str += " transactions. This will result in a fee of "; + prompt_str += print_money(ptx_vector.size() * DEFAULT_FEE); + prompt_str += ". Is this okay? (Y/Yes/N/No)"; + std::string accepted = command_line::input_line(prompt_str); + if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes") + { + fail_msg_writer() << "Transaction cancelled."; + + // would like to return false, because no tx made, but everything else returns true + // and I don't know what returning false might adversely affect. *sigh* + return true; + } + } + + // actually commit the transactions + while (!ptx_vector.empty()) + { + auto & ptx = ptx_vector.back(); + m_wallet->commit_tx(ptx); + success_msg_writer(true) << "Money successfully sent, transaction " << get_transaction_hash(ptx.tx); + + // if no exception, remove element from vector + ptx_vector.pop_back(); + } } catch (const tools::error::daemon_busy&) { @@ -899,16 +929,14 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_) { fail_msg_writer() << e.what(); } - catch (const tools::error::tx_too_big& e) - { - cryptonote::transaction tx = e.tx(); - fail_msg_writer() << "transaction " << get_transaction_hash(e.tx()) << " is too big. Transaction size: " << - get_object_blobsize(e.tx()) << " bytes, transaction size limit: " << e.tx_size_limit() << " bytes"; - } catch (const tools::error::zero_destination&) { fail_msg_writer() << "one of destinations is zero"; } + catch (const tools::error::tx_too_big& e) + { + fail_msg_writer() << "Failed to find a suitable way to split transactions"; + } catch (const tools::error::transfer_error& e) { LOG_ERROR("unknown transfer error: " << e.to_string()); |