From 07d353dfc67d588ab9972af9cb0c032da41e4d01 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 12 Jul 2016 13:18:09 +0100 Subject: [PATCH] wallet: handle 0 change properly With RCT, we allow 0 size outputs, to try and encourage txes with two inputs and two outputs. Consolidation would then have two non zero inputs, one zero output, and one larger output. --- src/wallet/wallet2.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index ef77f68c..d5645bd1 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -228,6 +228,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_ return; } + int num_vouts_received = 0; tx_pub_key = pub_key_field.pub_key; bool r = true; std::deque in_ephemeral(tx.vout.size()); @@ -262,6 +263,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_ money_transfered = tools::decodeRct(tx.rct_signatures, rct::sk2rct(in_ephemeral[0].sec), 0, mask[0]); amount[0] = money_transfered; tx_money_got_in_outs = money_transfered; + ++num_vouts_received; // process the other outs from that tx boost::asio::io_service ioservice; @@ -301,6 +303,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_ money_transfered[i] = tools::decodeRct(tx.rct_signatures, rct::sk2rct(in_ephemeral[i].sec), i, mask[i]); tx_money_got_in_outs += money_transfered[i]; amount[i] = money_transfered[i]; + ++num_vouts_received; } } } @@ -345,6 +348,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_ money_transfered[i] = tools::decodeRct(tx.rct_signatures, rct::sk2rct(in_ephemeral[i].sec), i, mask[i]); tx_money_got_in_outs += money_transfered[i]; amount[i] = money_transfered[i]; + ++num_vouts_received; } } } @@ -373,13 +377,14 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_ money_transfered = tools::decodeRct(tx.rct_signatures, rct::sk2rct(in_ephemeral[i].sec), i, mask[i]); amount[i] = money_transfered; tx_money_got_in_outs += money_transfered; + ++num_vouts_received; } } } } THROW_WALLET_EXCEPTION_IF(!r, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys()); - if(!outs.empty() && tx_money_got_in_outs) + if(!outs.empty() && num_vouts_received > 0) { //good news - got money! take care about it //usually we have only one transfer for user in transaction @@ -2969,12 +2974,8 @@ void wallet2::transfer_selected_rct(std::vector