aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-07-12 13:18:09 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-08-28 21:29:27 +0100
commit07d353dfc67d588ab9972af9cb0c032da41e4d01 (patch)
tree58014758c8d6f19431516706bd946b5a1f2bff04 /src/wallet/wallet2.cpp
parentport get_tx_key/check_tx_key to rct (diff)
downloadmonero-07d353dfc67d588ab9972af9cb0c032da41e4d01.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--src/wallet/wallet2.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index ef77f68c3..d5645bd1f 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<cryptonote::keypair> 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<cryptonote::tx_destination_entry
}
cryptonote::tx_destination_entry change_dts = AUTO_VAL_INIT(change_dts);
- if (needed_money < found_money)
- {
- change_dts.addr = m_account.get_keys().m_account_address;
- change_dts.amount = found_money - needed_money;
- }
-
+ change_dts.addr = m_account.get_keys().m_account_address;
+ change_dts.amount = found_money - needed_money; // may be 0, we allow 0 change
dsts.push_back(change_dts);
crypto::secret_key tx_key;