From 31abac4daf74f82cf9cd7c779ebb2ed8ded1d598 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 25 Oct 2016 21:19:47 +0100 Subject: wallet: fix pre-rct cold wallet signing not splitting change Re-creating the transaction on the cold wallet was not splitting the change, causing the transaction to be rejected by the network. This worked on testnet since amounts do not have to be split. Also add selected_transfers, which can now be saved since they're size_t rather than iterators. This allows the view wallet to properly set the sent outputs as spent and update balance. Bump transfer file version numbers to match. --- src/simplewallet/simplewallet.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 3f494f512..c8484dd5a 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -3128,9 +3128,9 @@ bool simple_wallet::accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs) if (mixin < min_mixin) min_mixin = mixin; } - for (size_t d = 0; d < cd.destinations.size(); ++d) + for (size_t d = 0; d < cd.splitted_dsts.size(); ++d) { - const tx_destination_entry &entry = cd.destinations[d]; + const tx_destination_entry &entry = cd.splitted_dsts[d]; std::string address = get_account_address_as_str(m_wallet->testnet(), entry.addr); std::unordered_map::iterator i = dests.find(address); if (i == dests.end()) @@ -3141,9 +3141,19 @@ bool simple_wallet::accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs) } if (cd.change_dts.amount > 0) { - dests.insert(std::make_pair(get_account_address_as_str(m_wallet->testnet(), cd.change_dts.addr), cd.change_dts.amount)); - amount_to_dests += cd.change_dts.amount; - change += cd.change_dts.amount; + std::unordered_map::iterator it = dests.find(get_account_address_as_str(m_wallet->testnet(), cd.change_dts.addr)); + if (it == dests.end()) + { + fail_msg_writer() << tr("Claimed change does not go to a paid address"); + return false; + } + if (it->second < cd.change_dts.amount) + { + fail_msg_writer() << tr("Claimed change is larger than payment to the change address"); + return false; + } + change = cd.change_dts.amount; + it->second -= cd.change_dts.amount; } } std::string dest_string; @@ -3158,7 +3168,7 @@ bool simple_wallet::accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs) dest_string = tr("with no destinations"); uint64_t fee = amount - amount_to_dests; - std::string prompt_str = (boost::format(tr("Loaded %lu transactions, for %s, fee %s, change %s, %s, with min mixin %lu (full details in log file). Is this okay? (Y/Yes/N/No)")) % (unsigned long)txs.txes.size() % print_money(amount) % print_money(fee) % print_money(change) % dest_string % (unsigned long)min_mixin).str(); + std::string prompt_str = (boost::format(tr("Loaded %lu transactions, for %s, fee %s, change %s, %s, with min mixin %lu. Is this okay? (Y/Yes/N/No)")) % (unsigned long)txs.txes.size() % print_money(amount) % print_money(fee) % print_money(change) % dest_string % (unsigned long)min_mixin).str(); std::string accepted = command_line::input_line(prompt_str); return is_it_true(accepted); } -- cgit v1.2.3 From 069d688cf71f5e80844f3cb2a16b275f0e7bdf29 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 25 Oct 2016 23:23:59 +0100 Subject: simplewallet: log transactions to submit in submit_transfer Not as trustworthy as this is in the view wallet, the one that's considered compromised. --- src/simplewallet/simplewallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index c8484dd5a..09c574528 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -3246,7 +3246,7 @@ bool simple_wallet::submit_transfer(const std::vector &args_) 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 << tr("Is this okay? (Y/Yes/N/No)"); + 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()) -- cgit v1.2.3