Merge pull request #1369

6d76072 simplewallet: remove double confirmation when submitting signed tx (moneromooo-monero)
92dea04 wallet2: fix wrong change being recorded for cold signed txes (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2016-11-24 13:00:32 +02:00
commit 2497a2d547
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
3 changed files with 11 additions and 54 deletions

View File

@ -2923,57 +2923,6 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args_)
return true; return true;
} }
// if more than one tx necessary, prompt user to confirm
if (m_wallet->always_confirm_transfers())
{
uint64_t total_sent = 0;
uint64_t total_fee = 0;
uint64_t dust_not_in_fee = 0;
uint64_t dust_in_fee = 0;
for (size_t n = 0; n < ptx_vector.size(); ++n)
{
total_fee += ptx_vector[n].fee;
for (auto i: ptx_vector[n].selected_transfers)
total_sent += m_wallet->get_transfer_details(i).amount();
total_sent -= ptx_vector[n].change_dts.amount + ptx_vector[n].fee;
if (ptx_vector[n].dust_added_to_fee)
dust_in_fee += ptx_vector[n].dust;
else
dust_not_in_fee += ptx_vector[n].dust;
}
std::stringstream prompt;
prompt << boost::format(tr("Sending %s. ")) % print_money(total_sent);
if (ptx_vector.size() > 1)
{
prompt << boost::format(tr("Your transaction needs to be split into %llu transactions. "
"This will result in a transaction fee being applied to each transaction, for a total fee of %s")) %
((unsigned long long)ptx_vector.size()) % print_money(total_fee);
}
else
{
prompt << boost::format(tr("The transaction fee is %s")) %
print_money(total_fee);
}
if (dust_in_fee != 0) prompt << boost::format(tr(", of which %s is dust from change")) % print_money(dust_in_fee);
if (dust_not_in_fee != 0) prompt << tr(".") << ENDL << boost::format(tr("A total of %s from dust change will be sent to dust address"))
% print_money(dust_not_in_fee);
prompt << tr(".") << ENDL << "Full transaction details are available in the log file" << ENDL << tr("Is this okay? (Y/Yes/N/No)");
std::string accepted = command_line::input_line(prompt.str());
if (std::cin.eof())
return true;
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
{
fail_msg_writer() << tr("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 // actually commit the transactions
while (!ptx_vector.empty()) while (!ptx_vector.empty())
{ {

View File

@ -2756,7 +2756,7 @@ void wallet2::add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t amo
utd.m_amount_out = 0; utd.m_amount_out = 0;
for (const auto &d: dests) for (const auto &d: dests)
utd.m_amount_out += d.amount; utd.m_amount_out += d.amount;
utd.m_amount_out += change_amount; utd.m_amount_out += change_amount; // dests does not contain change
utd.m_change = change_amount; utd.m_change = change_amount;
utd.m_sent_time = time(NULL); utd.m_sent_time = time(NULL);
utd.m_tx = (const cryptonote::transaction_prefix&)tx; utd.m_tx = (const cryptonote::transaction_prefix&)tx;
@ -3083,7 +3083,7 @@ bool wallet2::sign_tx(const std::string &unsigned_filename, const std::string &s
ptx.change_dts = sd.change_dts; ptx.change_dts = sd.change_dts;
ptx.selected_transfers = sd.selected_transfers; ptx.selected_transfers = sd.selected_transfers;
ptx.tx_key = rct::rct2sk(rct::identity()); // don't send it back to the untrusted view wallet ptx.tx_key = rct::rct2sk(rct::identity()); // don't send it back to the untrusted view wallet
ptx.dests = sd.splitted_dsts; ptx.dests = sd.dests;
ptx.construction_data = sd; ptx.construction_data = sd;
txs.push_back(ptx); txs.push_back(ptx);
@ -3682,6 +3682,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
ptx.construction_data.extra = tx.extra; ptx.construction_data.extra = tx.extra;
ptx.construction_data.unlock_time = unlock_time; ptx.construction_data.unlock_time = unlock_time;
ptx.construction_data.use_rct = false; ptx.construction_data.use_rct = false;
ptx.construction_data.dests = dsts;
} }
void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::list<size_t> selected_transfers, size_t fake_outputs_count, void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::list<size_t> selected_transfers, size_t fake_outputs_count,
@ -3802,6 +3803,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
ptx.construction_data.extra = tx.extra; ptx.construction_data.extra = tx.extra;
ptx.construction_data.unlock_time = unlock_time; ptx.construction_data.unlock_time = unlock_time;
ptx.construction_data.use_rct = true; ptx.construction_data.use_rct = true;
ptx.construction_data.dests = dsts;
} }
static size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs) static size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs)

View File

@ -191,11 +191,12 @@ namespace tools
{ {
std::vector<cryptonote::tx_source_entry> sources; std::vector<cryptonote::tx_source_entry> sources;
cryptonote::tx_destination_entry change_dts; cryptonote::tx_destination_entry change_dts;
std::vector<cryptonote::tx_destination_entry> splitted_dsts; std::vector<cryptonote::tx_destination_entry> splitted_dsts; // split, includes change
std::list<size_t> selected_transfers; std::list<size_t> selected_transfers;
std::vector<uint8_t> extra; std::vector<uint8_t> extra;
uint64_t unlock_time; uint64_t unlock_time;
bool use_rct; bool use_rct;
std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
BEGIN_SERIALIZE_OBJECT() BEGIN_SERIALIZE_OBJECT()
FIELD(sources) FIELD(sources)
@ -205,12 +206,16 @@ namespace tools
FIELD(extra) FIELD(extra)
VARINT_FIELD(unlock_time) VARINT_FIELD(unlock_time)
FIELD(use_rct) FIELD(use_rct)
FIELD(dests)
END_SERIALIZE() END_SERIALIZE()
}; };
typedef std::vector<transfer_details> transfer_container; typedef std::vector<transfer_details> transfer_container;
typedef std::unordered_multimap<crypto::hash, payment_details> payment_container; typedef std::unordered_multimap<crypto::hash, payment_details> payment_container;
// The convention for destinations is:
// dests does not include change
// splitted_dsts (in construction_data) does
struct pending_tx struct pending_tx
{ {
cryptonote::transaction tx; cryptonote::transaction tx;
@ -1048,6 +1053,7 @@ namespace tools
ptx.construction_data.extra = tx.extra; ptx.construction_data.extra = tx.extra;
ptx.construction_data.unlock_time = unlock_time; ptx.construction_data.unlock_time = unlock_time;
ptx.construction_data.use_rct = false; ptx.construction_data.use_rct = false;
ptx.construction_data.dests = dsts;
} }