Skip to content

Commit

Permalink
wallet2: don't store 0 amount outputs, they'll fail to be spent
Browse files Browse the repository at this point in the history
It's better to just ignore them, the user does not really need
to know they're here. If the mask is wrong, they'll fail to be
used, and sweeping will fail as it tries to use it.

Reported by Josh Davis.
  • Loading branch information
moneromooo-monero committed Mar 12, 2019
1 parent 1d1a02e commit bc61b5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wallet/wallet2.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1495,11 +1495,17 @@ void wallet2::scan_output(const cryptonote::transaction &tx, bool miner_tx, cons
} }


THROW_WALLET_EXCEPTION_IF(std::find(outs.begin(), outs.end(), i) != outs.end(), error::wallet_internal_error, "Same output cannot be added twice"); THROW_WALLET_EXCEPTION_IF(std::find(outs.begin(), outs.end(), i) != outs.end(), error::wallet_internal_error, "Same output cannot be added twice");
outs.push_back(i);
if (tx_scan_info.money_transfered == 0 && !miner_tx) if (tx_scan_info.money_transfered == 0 && !miner_tx)
{ {
tx_scan_info.money_transfered = tools::decodeRct(tx.rct_signatures, tx_scan_info.received->derivation, i, tx_scan_info.mask, m_account.get_device()); tx_scan_info.money_transfered = tools::decodeRct(tx.rct_signatures, tx_scan_info.received->derivation, i, tx_scan_info.mask, m_account.get_device());
} }
if (tx_scan_info.money_transfered == 0)
{
MERROR("Invalid output amount, skipping");
tx_scan_info.error = true;
return;
}
outs.push_back(i);
THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs[tx_scan_info.received->index] >= std::numeric_limits<uint64_t>::max() - tx_scan_info.money_transfered, THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs[tx_scan_info.received->index] >= std::numeric_limits<uint64_t>::max() - tx_scan_info.money_transfered,
error::wallet_internal_error, "Overflow in received amounts"); error::wallet_internal_error, "Overflow in received amounts");
tx_money_got_in_outs[tx_scan_info.received->index] += tx_scan_info.money_transfered; tx_money_got_in_outs[tx_scan_info.received->index] += tx_scan_info.money_transfered;
Expand Down

0 comments on commit bc61b5c

Please sign in to comment.