wallet2: only add a dummy 0 output if there's one output otherwise

This commit is contained in:
moneromooo-monero 2017-11-13 14:08:10 +00:00
parent af448d3883
commit 7e387fb1ad
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 14 additions and 10 deletions

View File

@ -4663,21 +4663,25 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
change_dts.amount = found_money - needed_money; change_dts.amount = found_money - needed_money;
if (change_dts.amount == 0) if (change_dts.amount == 0)
{ {
// If the change is 0, send it to a random address, to avoid confusing if (splitted_dsts.size() == 1)
// the sender with a 0 amount output. We send a 0 amount in order to avoid {
// letting the destination be able to work out which of the inputs is the // If the change is 0, send it to a random address, to avoid confusing
// real one in our rings // the sender with a 0 amount output. We send a 0 amount in order to avoid
LOG_PRINT_L2("generating dummy address for 0 change"); // letting the destination be able to work out which of the inputs is the
cryptonote::account_base dummy; // real one in our rings
dummy.generate(); LOG_PRINT_L2("generating dummy address for 0 change");
change_dts.addr = dummy.get_keys().m_account_address; cryptonote::account_base dummy;
LOG_PRINT_L2("generated dummy address for 0 change"); dummy.generate();
change_dts.addr = dummy.get_keys().m_account_address;
LOG_PRINT_L2("generated dummy address for 0 change");
splitted_dsts.push_back(change_dts);
}
} }
else else
{ {
change_dts.addr = get_subaddress({subaddr_account, 0}); change_dts.addr = get_subaddress({subaddr_account, 0});
splitted_dsts.push_back(change_dts);
} }
splitted_dsts.push_back(change_dts);
crypto::secret_key tx_key; crypto::secret_key tx_key;
std::vector<crypto::secret_key> additional_tx_keys; std::vector<crypto::secret_key> additional_tx_keys;