Add code comments

This commit is contained in:
pokkst 2022-09-22 17:13:19 -05:00
parent 55621e3465
commit 95d5b78542
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
2 changed files with 5 additions and 1 deletions

View File

@ -125,6 +125,7 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
long amount = sendAll ? Wallet.SWEEP_ALL : Wallet.getAmountFromString(amountStr);
ArrayList<String> preferredInputs;
if(selectedUtxos.isEmpty()) {
// no inputs manually selected, we are sending from home screen most likely, or user somehow broke the app
preferredInputs = UTXOService.getInstance().selectUtxos(amount, sendAll);
} else {
preferredInputs = selectedUtxos;

View File

@ -39,12 +39,15 @@ public class UTXOService extends ServiceBase {
List<CoinsInfo> utxos = getUtxos();
long amountSelected = 0;
Collections.shuffle(utxos);
//loop through each utxo
for (CoinsInfo coinsInfo : utxos) {
if(!coinsInfo.isSpent()) {
if(!coinsInfo.isSpent()) { //filter out spent outputs
if (sendAll) {
// if send all, add all utxos and set amount to send all
selectedUtxos.add(coinsInfo.getKeyImage());
amountSelected = Wallet.SWEEP_ALL;
} else {
//if amount selected is still less than amount needed, and the utxos tx hash hasn't already been seen, add utxo
if (amountSelected <= amount && !seenTxs.contains(coinsInfo.getHash())) {
selectedUtxos.add(coinsInfo.getKeyImage());
// we don't want to spend multiple utxos from the same transaction, so we prevent that from happening here.