Prevent locked UTXOs from being selected

This commit is contained in:
pokkst 2022-09-23 02:33:55 -05:00
parent 9187b9d8a4
commit 9b4cd9860a
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
5 changed files with 20 additions and 6 deletions

View File

@ -1083,7 +1083,7 @@ Java_net_mynero_wallet_model_Wallet_getCoinsJ(JNIEnv *env, jobject instance) {
jobject newCoinsInfo(JNIEnv *env, Monero::CoinsInfo *info) {
jmethodID c = env->GetMethodID(class_CoinsInfo, "<init>",
"(JZLjava/lang/String;JLjava/lang/String;Ljava/lang/String;)V");
"(JZLjava/lang/String;JLjava/lang/String;Ljava/lang/String;Z)V");
jstring _key_image = env->NewStringUTF(info->keyImage().c_str());
jstring _pub_key = env->NewStringUTF(info->pubKey().c_str());
jstring _hash = env->NewStringUTF(info->hash().c_str());
@ -1093,7 +1093,8 @@ jobject newCoinsInfo(JNIEnv *env, Monero::CoinsInfo *info) {
_key_image,
static_cast<jlong> (info->amount()),
_hash,
_pub_key);
_pub_key,
info->unlocked());
env->DeleteLocalRef(_key_image);
env->DeleteLocalRef(_hash);
env->DeleteLocalRef(_pub_key);

View File

@ -103,11 +103,16 @@ public class CoinsInfoAdapter extends RecyclerView.Adapter<CoinsInfoAdapter.View
amountTextView.setText(Wallet.getDisplayAmount(coinsInfo.getAmount()));
pubKeyTextView.setText(coinsInfo.getPubKey());
itemView.setOnLongClickListener(view -> {
boolean unlocked = coinsInfo.isUnlocked();
if(unlocked) {
listener.onUtxoSelected(coinsInfo);
return true;
}
return unlocked;
});
if(selected) {
if(!coinsInfo.isUnlocked()) {
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_locked_utxo));
} else if(selected) {
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_negativeColor));
} else {
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), android.R.color.transparent));

View File

@ -35,14 +35,16 @@ public class CoinsInfo implements Parcelable, Comparable<CoinsInfo> {
long amount;
String hash;
String pubKey;
boolean unlocked;
public CoinsInfo(long globalOutputIndex, boolean spent, String keyImage, long amount, String hash, String pubKey) {
public CoinsInfo(long globalOutputIndex, boolean spent, String keyImage, long amount, String hash, String pubKey, boolean unlocked) {
this.globalOutputIndex = globalOutputIndex;
this.spent = spent;
this.keyImage = keyImage;
this.amount = amount;
this.hash = hash;
this.pubKey = pubKey;
this.unlocked = unlocked;
}
protected CoinsInfo(Parcel in) {
@ -85,6 +87,10 @@ public class CoinsInfo implements Parcelable, Comparable<CoinsInfo> {
return pubKey;
}
public boolean isUnlocked() {
return unlocked;
}
@Override
public int describeContents() {
return 0;

View File

@ -29,6 +29,7 @@
<color name="oled_colorError">@color/oled_favouriteColor</color>
<color name="oled_colorOnError">#ffffff</color>
<color name="edittext_bg_color">#202020</color>
<color name="oled_locked_utxo">#956E43</color>
<!-- CLASSIC -->

View File

@ -30,6 +30,7 @@
<color name="oled_colorOnError">@color/oled_colorBackground</color>
<color name="edittext_bg_color">#CCCCCC</color>
<color name="button_disabled_bg_color">#454545</color>
<color name="oled_locked_utxo">#B5895A</color>
<!-- CLASSIC -->