mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-30 01:23:16 +00:00
sort UTXOs by value
This commit is contained in:
parent
1e1fffae00
commit
693b342393
3 changed files with 17 additions and 2 deletions
|
@ -19,6 +19,7 @@ import net.mynero.wallet.model.CoinsInfo;
|
||||||
import net.mynero.wallet.service.UTXOService;
|
import net.mynero.wallet.service.UTXOService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInfoAdapterListener {
|
public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInfoAdapterListener {
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf
|
||||||
filteredUtxos.add(coinsInfo);
|
filteredUtxos.add(coinsInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort(filteredUtxos);
|
||||||
if (filteredUtxos.isEmpty()) {
|
if (filteredUtxos.isEmpty()) {
|
||||||
utxosRecyclerView.setVisibility(View.GONE);
|
utxosRecyclerView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import androidx.annotation.NonNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CoinsInfo implements Parcelable {
|
public class CoinsInfo implements Parcelable, Comparable<CoinsInfo> {
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("monerujo");
|
System.loadLibrary("monerujo");
|
||||||
}
|
}
|
||||||
|
@ -94,4 +94,17 @@ public class CoinsInfo implements Parcelable {
|
||||||
public void writeToParcel(@NonNull Parcel parcel, int i) {
|
public void writeToParcel(@NonNull Parcel parcel, int i) {
|
||||||
parcel.writeLong(globalOutputIndex);
|
parcel.writeLong(globalOutputIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(CoinsInfo another) {
|
||||||
|
long b1 = this.amount;
|
||||||
|
long b2 = another.amount;
|
||||||
|
if (b1 > b2) {
|
||||||
|
return -1;
|
||||||
|
} else if (b1 < b2) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return this.hash.compareTo(another.hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class UTXOService extends ServiceBase {
|
||||||
ArrayList<String> seenTxs = new ArrayList<>();
|
ArrayList<String> seenTxs = new ArrayList<>();
|
||||||
List<CoinsInfo> utxos = getUtxos();
|
List<CoinsInfo> utxos = getUtxos();
|
||||||
long amountSelected = 0;
|
long amountSelected = 0;
|
||||||
Collections.shuffle(utxos);
|
Collections.sort(utxos);
|
||||||
//loop through each utxo
|
//loop through each utxo
|
||||||
for (CoinsInfo coinsInfo : utxos) {
|
for (CoinsInfo coinsInfo : utxos) {
|
||||||
if(!coinsInfo.isSpent()) { //filter out spent outputs
|
if(!coinsInfo.isSpent()) { //filter out spent outputs
|
||||||
|
|
Loading…
Reference in a new issue