Updated on 2026-08-14
This commit is contained in:
parent
c11defad59
commit
ec87412ebe
4 changed files with 28 additions and 17 deletions
|
|
@ -30,7 +30,7 @@ public class BalanceValidator {
|
|||
secondLine = "";
|
||||
|
||||
// rule 1
|
||||
if(!CheckOfflineBalance(card) && !CheckOnlineBalance(card)) {
|
||||
if((!CheckOfflineBalance(card) && !CheckOnlineBalance(card)) || (!CheckOnlineBalance(card) && HasEverSigned(card))) {
|
||||
score = 0;
|
||||
firstLine = "Unknown balance";
|
||||
secondLine = "Balance cannot be verified. Swipe down to refresh.";
|
||||
|
|
@ -62,10 +62,20 @@ public class BalanceValidator {
|
|||
}
|
||||
|
||||
// rule 5
|
||||
if(IsLostSecondRead(card))
|
||||
if(!isCodeConfirmed(card))
|
||||
{
|
||||
score = 0;
|
||||
secondLine = "Wallet and note keys were not verified. Tap again. ";
|
||||
firstLine = "Not genuine banknote";
|
||||
secondLine = "Firmware binary code verification failed";
|
||||
return;
|
||||
}
|
||||
|
||||
// rule 5
|
||||
if(card.PIN2 == TangemCard.PIN2_Mode.CustomPIN2)
|
||||
{
|
||||
score = 0;
|
||||
firstLine = "Locked with PIN2";
|
||||
secondLine = "Ask the holder to disable PIN2 before accepting";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +89,7 @@ public class BalanceValidator {
|
|||
}
|
||||
|
||||
// rule 4 TODO: need to check SignedHashed against number of outputs in blockchain
|
||||
if(HasEverSigned(card))
|
||||
if(HasEverSigned(card) && card.getBalance() != 0)
|
||||
{
|
||||
score = 80;
|
||||
firstLine = "Unguaranteed balance";
|
||||
|
|
@ -87,7 +97,7 @@ public class BalanceValidator {
|
|||
return;
|
||||
}
|
||||
// rule 7
|
||||
if(CheckOfflineBalance(card) && !CheckOnlineBalance(card))
|
||||
if(CheckOfflineBalance(card) && !CheckOnlineBalance(card) && !HasEverSigned(card) && card.getBalance() != 0)
|
||||
{
|
||||
score = 80;
|
||||
firstLine = "Verified offline balance";
|
||||
|
|
@ -157,8 +167,8 @@ public class BalanceValidator {
|
|||
return card.getBalanceUnconfirmed()!=0;
|
||||
}
|
||||
|
||||
boolean IsLostSecondRead(TangemCard card)
|
||||
boolean isCodeConfirmed(TangemCard card)
|
||||
{
|
||||
return card.isCodeConfirmed() != null;
|
||||
return card.isCodeConfirmed() == null || card.isCodeConfirmed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ public class TangemCard {
|
|||
private float rate = 0;
|
||||
private float rateAlter = 0;
|
||||
|
||||
// public static final int SettingsMask_AllowSwapPIN = 0x0010;
|
||||
// public static final int SettingsMask_IsReusable = 0x0001;
|
||||
// public static final int SettingsMask_UseRecovery = 0x0002;
|
||||
// public static final int SettingsMask_UseBlock = 0x0004;
|
||||
//
|
||||
// public static final int SettingsMask_AllowSwapPIN = 0x0010;
|
||||
// public static final int SettingsMask_AllowSwapPIN2 = 0x0020;
|
||||
// public static final int SettingsMask_UseCVC = 0x0040;
|
||||
//
|
||||
|
|
|
|||
|
|
@ -201,9 +201,9 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
|
||||
btnExtract.setOnClickListener {
|
||||
if (!mCard!!.hasBalanceInfo()) {
|
||||
|
||||
} else if (!engine!!.IsBalanceNotZero(mCard))
|
||||
if (!mCard!!.hasBalanceInfo())
|
||||
Toast.makeText(context, R.string.cannot_obtain_data_from_blockchain, Toast.LENGTH_LONG).show()
|
||||
else if (!engine!!.IsBalanceNotZero(mCard))
|
||||
Toast.makeText(context, R.string.wallet_empty, Toast.LENGTH_LONG).show()
|
||||
else if (!engine.IsBalanceAlterNotZero(mCard))
|
||||
Toast.makeText(context, R.string.not_enough_funds, Toast.LENGTH_LONG).show()
|
||||
|
|
@ -213,11 +213,12 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
Toast.makeText(context, R.string.please_wait_for_confirmation, Toast.LENGTH_LONG).show()
|
||||
else if (mCard!!.remainingSignatures == 0)
|
||||
Toast.makeText(context, R.string.card_hasn_t_remaining_signature, Toast.LENGTH_LONG).show()
|
||||
|
||||
val intent = Intent(context, PreparePaymentActivity::class.java)
|
||||
intent.putExtra("UID", mCard!!.uid)
|
||||
intent.putExtra("Card", mCard!!.asBundle)
|
||||
startActivityForResult(intent, REQUEST_CODE_SEND_PAYMENT)
|
||||
else {
|
||||
val intent = Intent(context, PreparePaymentActivity::class.java)
|
||||
intent.putExtra("UID", mCard!!.uid)
|
||||
intent.putExtra("Card", mCard!!.asBundle)
|
||||
startActivityForResult(intent, REQUEST_CODE_SEND_PAYMENT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue