Updated on 2026-08-14

This commit is contained in:
Tangem 2018-07-17 11:27:48 +03:00
commit df94a313e8
3 changed files with 42 additions and 37 deletions

View file

@ -13,13 +13,17 @@ public class BalanceValidator {
public String GetSecondLine()
{
if(score < 0) score = 0;
return score + "% safe. " + secondLine;
if (score ==0) {
return "Do not accept. " + secondLine;
} else {
return score + "% safe. " + secondLine;
}
}
public void Check(TangemCard card)
{
String defaultFirstLine = "Unknown balance.";
String successFirstLine = "Verified balance.";
String defaultFirstLine = "Unknown balance";
String successFirstLine = "Verified balance";
firstLine = successFirstLine;
secondLine = "";
@ -27,14 +31,14 @@ public class BalanceValidator {
// rule 1
if(!CheckOfflineBalance(card) && !CheckOnlineBalance(card)) {
score = 0;
secondLine = "Do not accept. Balance cannot be verified.";
secondLine = "Balance cannot be verified.";
firstLine = defaultFirstLine;
return;
}
// rule 2.a
if(!VerificationWalletKey(card)) {
score = 0;
secondLine = "Do not accept. Wallet verification failed.";
secondLine = "Wallet verification failed.";
firstLine = defaultFirstLine;
return;
}
@ -43,7 +47,7 @@ public class BalanceValidator {
// rule 2.c
if(!CheckAttestationServiceResult(card)) {
score = 0;
secondLine = "Do not accept. Tangem Attestation service says card is not genuine.";
secondLine = "Do not accept. Tangem Attestation service says card is not genuine. ";
firstLine = successFirstLine;
return;
}
@ -53,32 +57,32 @@ public class BalanceValidator {
{
if(card.isBalanceRecieved() && card.isBalanceEqual()) {
score = 100;
firstLine = "Verified balance.";
secondLine += " Confirmed balance and banknote identity.";
firstLine = "Verified balance";
secondLine += " Confirmed balance and banknote identity. ";
}
if(card.getFailedBalanceRequestCounter()!=0) {
score = 100 - 10 * card.getFailedBalanceRequestCounter();
firstLine = "Verified balance.";
secondLine += " Not all nodes have returned balance. App is requesting more nodes to be 100% sure...";
score = 100 - 5 * card.getFailedBalanceRequestCounter();
firstLine = "Verified balance";
secondLine += "Not all nodes have returned balance. Swipe down to refresh. ";
if(score <= 0)
return;
}
if(card.isBalanceRecieved() && !card.isBalanceEqual()) {
score = 0;
firstLine = "Disputed balance.";
secondLine += " Cannot obtaine trusted balance at the moment. Try to tap and check this banknote later.";
return;
}
//
// if(card.isBalanceRecieved() && !card.isBalanceEqual()) {
// score = 0;
// firstLine = "Disputed balance";
// secondLine += " Cannot obtain trusted balance at the moment. Try to tap and check this banknote later.";
// return;
// }
}
// rule 7
if(CheckOfflineBalance(card) && !CheckOnlineBalance(card))
{
score = -10;
String firstLine = "Virified offline balance.";
secondLine += " Restore internet connection to be more confidient.";
score -= 10;
String firstLine = "Verified offline balance";
secondLine += "Restore internet connection to be more confidient. ";
if(score <= 0)
return;
}
@ -86,8 +90,8 @@ public class BalanceValidator {
// rule 2.b
if(!CheckAttestationServiceAvailable(card))
{
score = -15;
secondLine += "Card identity was not verified. Cannot reach attestation service.";
score -= 15;
secondLine += "Card identity was not verified. Cannot reach attestation service. ";
firstLine = successFirstLine;
if(score <= 0)
return;
@ -96,8 +100,8 @@ public class BalanceValidator {
// rule 5
if(IsLostSecondRead(card))
{
score = -30;
secondLine += " Wallet and banknote keys were not verified (tap again).";
score -= 30;
secondLine += "Wallet and banknote keys were not verified (tap again). ";
if(score <= 0)
return;
}
@ -105,9 +109,9 @@ public class BalanceValidator {
// rule 4
if(!CheckSignHashes(card))
{
score = -50;
secondLine = "Unguaranteed balance.";
firstLine += " Potential unsent transaction at the moment. Try to tap and check this banknote later.";
score -= 50;
secondLine = "Unguaranteed balance";
firstLine += "Potential unsent transaction at the moment. Try to tap and check this banknote later. ";
if(score <= 0)
return;
}
@ -115,9 +119,9 @@ public class BalanceValidator {
// rule 6
if(NotConfirmTransaction(card))
{
score = -50;
String firstLine = "Unguaranted balance.";
secondLine = " Loading in progress. Wait for full confirmation in blockchain.";
score -= 50;
String firstLine = "Unguaranted balance";
secondLine += " Loading in progress. Wait for full confirmation in blockchain. ";
if(score <= 0)
return;
}

View file

@ -1543,6 +1543,8 @@ public class TangemCard {
return R.drawable.card_btc001;
else if (bytesToHex(getDenomination()).equals("404B4C0000000000"))
return R.drawable.card_btc005;
else if (bytesToHex(getDenomination()).equals("0000000000000000"))
return R.drawable.card_btc_hk_s;
else
return R.drawable.card_default;

View file

@ -141,11 +141,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="@font/montserrat_light"
android:text="Verified balance"
android:textAlignment="center"
android:textColor="@color/msg_okay"
android:textSize="18sp"
tools:text="Verified balance" />
android:textSize="18sp" />
<TextView
android:id="@+id/tvBalanceLine2"
@ -153,7 +151,6 @@
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="@font/montserrat_light"
android:text="100% safe\nConfirmed balance and banknote identity"
android:textAlignment="center" />
</LinearLayout>
@ -431,7 +428,8 @@
android:text="@string/message"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="normal|bold"/>
android:textStyle="normal|bold"
android:visibility="gone" />
<TextView
android:id="@+id/tvError"
@ -447,7 +445,8 @@
android:text="@string/error"
android:textAlignment="center"
android:textColor="@color/white"
android:textStyle="bold"/>
android:textStyle="bold"
android:visibility="gone" />
</RelativeLayout>