Updated on 2026-08-14
This commit is contained in:
parent
c74374611a
commit
0f30672177
6 changed files with 76 additions and 28 deletions
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
|
|
@ -4,15 +4,11 @@ import android.content.Context;
|
|||
import android.nfc.tech.IsoDep;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.FW;
|
||||
import com.tangem.domain.cardReader.NfcManager;
|
||||
import com.tangem.domain.wallet.PINStorage;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.util.Util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.domain
|
||||
|
||||
enum class BitcoinNodeTestNet(val host: String, val port: Int) {
|
||||
qtornado_com("testnet.qtornado.com", 51001),
|
||||
hsmiths_com("testnet.hsmiths.com", 53011),
|
||||
bauerj_eu("testnet1.bauerj.eu", 50001),
|
||||
arihanc_com("testnetnode.arihanc.com", 51001),
|
||||
n1("testnetnode.arihanc.com", 51001),
|
||||
n2("testnet.hsmiths.com", 53011),
|
||||
n3("testnet.qtornado.com", 51001),
|
||||
n4("testnet1.bauerj.eu", 50001),
|
||||
}
|
||||
|
|
@ -470,7 +470,11 @@ public class CardProtocol {
|
|||
|
||||
// try read denomination
|
||||
if (tlvIssuerData != null && tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination) != null) {
|
||||
mCard.setDenomination(tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination).Value);
|
||||
if(tlvIssuerData.getTLV(TLV.Tag.TAG_DenominationText) != null) {
|
||||
mCard.setDenomination(tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination).Value, tlvIssuerData.getTLV(TLV.Tag.TAG_DenominationText).getAsString());
|
||||
}else{
|
||||
mCard.setDenomination(tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination).Value);
|
||||
}
|
||||
} else {
|
||||
mCard.clearDenomination();
|
||||
}
|
||||
|
|
@ -504,6 +508,8 @@ public class CardProtocol {
|
|||
|
||||
TLVList tlvCardData = TLVList.fromBytes(readResult.getTLV(TLV.Tag.TAG_CardData).Value);
|
||||
|
||||
mCard.setBatch(tlvCardData.getTLV(TLV.Tag.TAG_Batch).getAsHexString());
|
||||
|
||||
TLV tokenSymbol = tlvCardData.getTLV(TLV.Tag.TAG_Token_Symbol);
|
||||
TLV contractAddress = tlvCardData.getTLV(TLV.Tag.TAG_Token_Contract_Address);
|
||||
TLV tokens_decimal = tlvCardData.getTLV(TLV.Tag.TAG_Token_Decimal);
|
||||
|
|
@ -974,6 +980,9 @@ public class CardProtocol {
|
|||
Log.i(logTag, String.format("OK: [%04X]\n%s", rspApdu.getSW1SW2(), rspApdu.getTLVs().getParsedTLVs(" ")));
|
||||
TLV issuerData = rspApdu.getTLVs().getTLV(TLV.Tag.TAG_Issuer_Data);
|
||||
TLV issuerDataSignature = rspApdu.getTLVs().getTLV(TLV.Tag.TAG_Issuer_Data_Signature);
|
||||
TLV issuerDataCounter = rspApdu.getTLVs().getTLV(TLV.Tag.TAG_Issuer_Data_Counter);
|
||||
|
||||
boolean protectIssuerDataAgainstReplay=(readResult.getTagAsInt(TLV.Tag.TAG_SettingsMask)&SettingsMask.ProtectIssuerDataAgainstReplay)!=0;
|
||||
|
||||
if (issuerData == null || issuerDataSignature == null)
|
||||
throw new TangemException("Invalid answer format (GetIssuerData)");
|
||||
|
|
@ -981,6 +990,9 @@ public class CardProtocol {
|
|||
ByteArrayOutputStream bsDataToVerify = new ByteArrayOutputStream();
|
||||
bsDataToVerify.write(mCard.getCID());
|
||||
bsDataToVerify.write(issuerData.Value);
|
||||
if( protectIssuerDataAgainstReplay ) {
|
||||
bsDataToVerify.write(issuerDataCounter.Value);
|
||||
}
|
||||
try {
|
||||
if (CardCrypto.VerifySignature(mCard.getIssuer().getPublicDataKey(), bsDataToVerify.toByteArray(), issuerDataSignature.Value)) {
|
||||
mCard.setIssuerData(issuerData.Value, issuerDataSignature.Value);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,8 @@ public class TLV {
|
|||
TAG_Token_Decimal(0xA2),
|
||||
TAG_Denomination(0xC0),
|
||||
TAG_ValidatedBalance(0xC1),
|
||||
TAG_LastSign_Date(0xC2);
|
||||
TAG_LastSign_Date(0xC2),
|
||||
TAG_DenominationText(0xC3);
|
||||
|
||||
|
||||
Tag(int Code) {
|
||||
|
|
|
|||
|
|
@ -271,6 +271,7 @@ public class TangemCard {
|
|||
}
|
||||
|
||||
private Boolean codeConfirmed;
|
||||
|
||||
public void setCodeConfirmed(Boolean codeConfirmed) {
|
||||
this.codeConfirmed = codeConfirmed;
|
||||
}
|
||||
|
|
@ -280,6 +281,7 @@ public class TangemCard {
|
|||
}
|
||||
|
||||
private Boolean onlineVerified;
|
||||
|
||||
public void setOnlineVerified(Boolean verified) {
|
||||
this.onlineVerified = verified;
|
||||
}
|
||||
|
|
@ -289,6 +291,7 @@ public class TangemCard {
|
|||
}
|
||||
|
||||
private Boolean onlineValidated;
|
||||
|
||||
public void setOnlineValidated(Boolean validated) {
|
||||
this.onlineValidated = validated;
|
||||
}
|
||||
|
|
@ -654,8 +657,8 @@ public class TangemCard {
|
|||
return issuer.getOfficialName();
|
||||
}
|
||||
|
||||
byte[] issuerData;
|
||||
byte[] issuerDataSignature;
|
||||
private byte[] issuerData;
|
||||
private byte[] issuerDataSignature;
|
||||
|
||||
public byte[] getIssuerData() {
|
||||
return issuerData;
|
||||
|
|
@ -667,9 +670,10 @@ public class TangemCard {
|
|||
|
||||
public void setIssuerData(byte[] value, byte[] signature) {
|
||||
issuerData = value;
|
||||
issuerDataSignature = signature;
|
||||
}
|
||||
|
||||
boolean needWriteIssuerData = false;
|
||||
private boolean needWriteIssuerData = false;
|
||||
|
||||
public boolean getNeedWriteIssuerData() {
|
||||
return needWriteIssuerData;
|
||||
|
|
@ -828,6 +832,16 @@ public class TangemCard {
|
|||
return numbers1[0] > numbers2[0] || (numbers1[0] == numbers2[0] && numbers1[1] > numbers2[1]);
|
||||
}
|
||||
|
||||
private String batch;
|
||||
|
||||
public void setBatch(String batch) {
|
||||
this.batch = batch;
|
||||
}
|
||||
|
||||
public String getBatch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
private String validationNodeDescription = "";
|
||||
|
||||
public String getValidationNodeDescription() {
|
||||
|
|
@ -1153,17 +1167,39 @@ public class TangemCard {
|
|||
}
|
||||
|
||||
private byte[] Denomination;
|
||||
private String DenominationText;
|
||||
|
||||
public void setDenomination(byte[] denomination) {
|
||||
public void setDenomination(byte[] denomination, String denominationText) {
|
||||
this.Denomination = denomination;
|
||||
this.DenominationText=denominationText;
|
||||
}
|
||||
|
||||
public void setDenomination(byte[] denomination)
|
||||
{
|
||||
this.Denomination=denomination;
|
||||
try {
|
||||
this.DenominationText=CoinEngineFactory.Create(getBlockchain()).ConvertByteArrayToAmount(this, denomination);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.DenominationText="N/A";
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getDenomination() {
|
||||
return Denomination;
|
||||
}
|
||||
|
||||
public String getDenominationText() {
|
||||
return DenominationText;
|
||||
}
|
||||
|
||||
public void setDenominationText(String denominationText) {
|
||||
DenominationText = denominationText;
|
||||
}
|
||||
|
||||
public void clearDenomination() {
|
||||
Denomination = null;
|
||||
DenominationText=null;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
|
|
@ -1232,6 +1268,7 @@ public class TangemCard {
|
|||
if (encryptionMode != null) B.putString("EncryptionMode", encryptionMode.name());
|
||||
if (issuer != null) B.putString("Issuer", issuer.getID());
|
||||
if (firmwareVersion != null) B.putString("FirmwareVersion", firmwareVersion);
|
||||
if (batch != null) B.putString("Batch", batch);
|
||||
B.putString("BalanceDecimal", balanceDecimal);
|
||||
B.putString("BalanceDecimalAlter", balanceDecimalAlter);
|
||||
B.putBoolean("ManufacturerConfirmed", manufacturerConfirmed);
|
||||
|
|
@ -1283,16 +1320,16 @@ public class TangemCard {
|
|||
B.putFloat("rateAlter", rateAlter);
|
||||
B.putString("confirmTx", GetConfirmTXCount().toString(16));
|
||||
|
||||
if( codeConfirmed!=null )
|
||||
if (codeConfirmed != null)
|
||||
B.putBoolean("codeConfirmed", codeConfirmed);
|
||||
|
||||
if( codeConfirmed!=null )
|
||||
if (codeConfirmed != null)
|
||||
B.putBoolean("codeConfirmed", codeConfirmed);
|
||||
|
||||
if( onlineVerified!=null )
|
||||
if (onlineVerified != null)
|
||||
B.putBoolean("onlineVerified", onlineVerified);
|
||||
|
||||
if( onlineValidated!=null )
|
||||
if (onlineValidated != null)
|
||||
B.putBoolean("onlineValidated", onlineValidated);
|
||||
|
||||
}
|
||||
|
|
@ -1334,6 +1371,7 @@ public class TangemCard {
|
|||
|
||||
if (B.containsKey("Issuer")) issuer = Issuer.FindIssuer(B.getString("Issuer"));
|
||||
if (B.containsKey("FirmwareVersion")) firmwareVersion = B.getString("FirmwareVersion");
|
||||
if (B.containsKey("Batch")) batch = B.getString("Batch");
|
||||
|
||||
cardPublicKeyValid = B.getBoolean("CardPublicKeyValid");
|
||||
if (B.containsKey("CardPublicKey")) setCardPublicKey(B.getByteArray("CardPublicKey"));
|
||||
|
|
@ -1350,7 +1388,7 @@ public class TangemCard {
|
|||
if (B.containsKey("Denomination")) setDenomination(B.getByteArray("Denomination"));
|
||||
else clearDenomination();
|
||||
|
||||
if (B.containsKey("IssuerData"))
|
||||
if (B.containsKey("IssuerData") && B.containsKey("IssuerDataSignature"))
|
||||
setIssuerData(B.getByteArray("IssuerData"), B.getByteArray("IssuerDataSignature"));
|
||||
else setIssuerData(null, null);
|
||||
|
||||
|
|
@ -1405,21 +1443,22 @@ public class TangemCard {
|
|||
if (B.containsKey("confirmTx"))
|
||||
countConfirmTX = new BigInteger(B.getString("confirmTx"), 16);
|
||||
|
||||
if( B.containsKey("codeConfirmed") )
|
||||
codeConfirmed=B.getBoolean("codeConfirmed");
|
||||
if (B.containsKey("codeConfirmed"))
|
||||
codeConfirmed = B.getBoolean("codeConfirmed");
|
||||
|
||||
if( B.containsKey("onlineVerified") )
|
||||
onlineVerified=B.getBoolean("onlineVerified");
|
||||
if (B.containsKey("onlineVerified"))
|
||||
onlineVerified = B.getBoolean("onlineVerified");
|
||||
|
||||
if( B.containsKey("onlineValidated") )
|
||||
onlineValidated=B.getBoolean("onlineValidated");
|
||||
if (B.containsKey("onlineValidated"))
|
||||
onlineValidated = B.getBoolean("onlineValidated");
|
||||
}
|
||||
|
||||
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
if (bytes == null) return "";
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
for ( int j = 0; j < bytes.length; j++ ) {
|
||||
for (int j = 0; j < bytes.length; j++) {
|
||||
int v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
|
|
@ -1430,9 +1469,9 @@ public class TangemCard {
|
|||
public int getCardImageResource() {
|
||||
switch (getBlockchainID()) {
|
||||
case "BTC":
|
||||
if ( bytesToHex(getDenomination()).equals("40420F0000000000") )
|
||||
if (bytesToHex(getDenomination()).equals("40420F0000000000"))
|
||||
return R.drawable.card_btc001;
|
||||
else if (bytesToHex(getDenomination()).equals("404B4C0000000000") )
|
||||
else if (bytesToHex(getDenomination()).equals("404B4C0000000000"))
|
||||
return R.drawable.card_btc005;
|
||||
else
|
||||
return R.drawable.card_default;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue