aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-10-25 21:19:47 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-10-25 21:44:31 +0100
commit31abac4daf74f82cf9cd7c779ebb2ed8ded1d598 (patch)
tree089a43e6b480fd5c2db32c016ea8356fe9c01b6e /src/simplewallet
parentMerge pull request #1253 (diff)
downloadmonero-31abac4daf74f82cf9cd7c779ebb2ed8ded1d598.tar.xz
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.
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp22
1 files changed, 16 insertions, 6 deletions
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<std::string,uint64_t>::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<std::string, uint64_t>::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);
}