Updated on 2026-08-14
This commit is contained in:
commit
ec23bfe658
22 changed files with 178 additions and 306 deletions
|
|
@ -15,7 +15,7 @@ android {
|
|||
applicationId "com.tangem.wallet"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
versionCode 89
|
||||
versionCode 91
|
||||
versionName "0.89.2." + generateVersionName()
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
|
|
@ -129,11 +129,6 @@
|
|||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tangem.presentation.activity.SettingsDebugActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tangem.presentation.activity.PrepareCryptonitWithdrawalActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
|
@ -149,7 +144,6 @@
|
|||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -103,7 +103,6 @@ public class ServerApiHelper {
|
|||
|
||||
public interface InfuraBodyListener {
|
||||
void onInfuraSuccess(String method, InfuraResponse infuraResponse);
|
||||
|
||||
void onInfuraFail(String method, String message);
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +167,8 @@ public class ServerApiHelper {
|
|||
private CardVerifyAndGetInfoListener cardVerifyAndGetInfoListener;
|
||||
|
||||
public interface CardVerifyAndGetInfoListener {
|
||||
void onCardVerifyAndGetInfo(CardVerifyAndGetInfo.Response cardVerifyAndGetArtworkResponse);
|
||||
void onSuccess(CardVerifyAndGetInfo.Response cardVerifyAndGetArtworkResponse);
|
||||
void onFail(String message);
|
||||
}
|
||||
|
||||
public void setCardVerifyAndGetInfoListener(CardVerifyAndGetInfoListener listener) {
|
||||
|
|
@ -189,14 +189,17 @@ public class ServerApiHelper {
|
|||
public void onResponse(@NonNull Call<CardVerifyAndGetInfo.Response> call, @NonNull Response<CardVerifyAndGetInfo.Response> response) {
|
||||
if (response.code() == 200) {
|
||||
CardVerifyAndGetInfo.Response cardVerifyAndGetArtworkResponse = response.body();
|
||||
cardVerifyAndGetInfoListener.onCardVerifyAndGetInfo(cardVerifyAndGetArtworkResponse);
|
||||
cardVerifyAndGetInfoListener.onSuccess(cardVerifyAndGetArtworkResponse);
|
||||
Log.i(TAG, "cardVerifyAndGeInfo onResponse " + response.code());
|
||||
} else
|
||||
} else {
|
||||
cardVerifyAndGetInfoListener.onFail(String.valueOf(response.code()));
|
||||
Log.e(TAG, "cardVerifyAndGetInfo onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CardVerifyAndGetInfo.Response> call, @NonNull Throwable t) {
|
||||
cardVerifyAndGetInfoListener.onFail(t.getMessage());
|
||||
Log.e(TAG, "cardVerifyAndGetInfo onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
|
|
@ -209,7 +212,8 @@ public class ServerApiHelper {
|
|||
private ArtworkListener artworkListener;
|
||||
|
||||
public interface ArtworkListener {
|
||||
void onArtwork(String artworkId, InputStream inputStream, Date updateDate);
|
||||
void onSuccess(String artworkId, InputStream inputStream, Date updateDate);
|
||||
void onFail(String message);
|
||||
}
|
||||
|
||||
public void setArtworkListener(ArtworkListener listener) {
|
||||
|
|
@ -228,7 +232,7 @@ public class ServerApiHelper {
|
|||
try {
|
||||
ResponseBody body = response.body();
|
||||
if (body != null) {
|
||||
artworkListener.onArtwork(artworkId, body.byteStream(), updateDate);
|
||||
artworkListener.onSuccess(artworkId, body.byteStream(), updateDate);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -238,6 +242,7 @@ public class ServerApiHelper {
|
|||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
|
||||
artworkListener.onFail(t.getMessage());
|
||||
Log.e(TAG, "getArtwork onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ public class SignPaymentTask extends Thread {
|
|||
}
|
||||
|
||||
Intent intent = new Intent(mContext, SendTransactionActivity.class);
|
||||
intent.putExtra(SendTransactionActivity.EXTRA_UID, mCard.getUID());
|
||||
intent.putExtra(SendTransactionActivity.EXTRA_CARD, mCard.getAsBundle());
|
||||
intent.putExtra(TangemCard.EXTRA_UID, mCard.getUID());
|
||||
intent.putExtra(TangemCard.EXTRA_CARD, mCard.getAsBundle());
|
||||
intent.putExtra(SendTransactionActivity.EXTRA_TX, txStr);
|
||||
mContext.startActivityForResult(intent, SignPaymentActivity.REQUEST_CODE_SEND_PAYMENT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,13 @@ package com.tangem.domain.wallet;
|
|||
import android.os.Bundle;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.tangem.data.network.Kraken;
|
||||
import com.tangem.domain.cardReader.SettingsMask;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.util.FormatUtil;
|
||||
import com.tangem.util.Util;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
|
@ -58,18 +54,22 @@ public class TangemCard {
|
|||
}
|
||||
return countConfirmedTX;
|
||||
}
|
||||
|
||||
public void setConfirmedTXCount(BigInteger count) {
|
||||
countConfirmedTX = count;
|
||||
}
|
||||
|
||||
public BigInteger getUnconfirmedTXCount() {
|
||||
if (countUnconfirmedTX == null) {
|
||||
countUnconfirmedTX = BigInteger.valueOf(0);
|
||||
}
|
||||
return countUnconfirmedTX;
|
||||
}
|
||||
|
||||
public void setUnconfirmedTXCount(BigInteger count) {
|
||||
countUnconfirmedTX = count;
|
||||
}
|
||||
|
||||
public float getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
|
@ -109,17 +109,17 @@ public class TangemCard {
|
|||
|
||||
}
|
||||
|
||||
private String blochchainName = "";
|
||||
private String blockchainName = "";
|
||||
|
||||
public void setBlockchainName(String name) {
|
||||
blochchainName = name;
|
||||
blockchainName = name;
|
||||
}
|
||||
|
||||
|
||||
public String getBlockchainName() {
|
||||
if (Strings.isNullOrEmpty(blochchainName))
|
||||
if (Strings.isNullOrEmpty(blockchainName))
|
||||
return getBlockchain().getOfficialName();
|
||||
return blochchainName;
|
||||
return blockchainName;
|
||||
}
|
||||
|
||||
public void setBlockchainIDFromCard(String blockchainID) {
|
||||
|
|
@ -287,11 +287,12 @@ public class TangemCard {
|
|||
public void clearInfo() {
|
||||
balanceConfirmed = null;
|
||||
balanceUnconfirmed = null;
|
||||
mUnspentTransactions = null;
|
||||
unspentTransactions = null;
|
||||
balanceDecimal = null;
|
||||
balanceDecimalAlter = null;
|
||||
setIsBalanceEqual(false);
|
||||
if (tokenSymbol.length() > 1) blockchainID = Blockchain.Token.getID(); // Reset blockchain to Token from ETH for token cards with zero token balance on it
|
||||
if (tokenSymbol.length() > 1)
|
||||
blockchainID = Blockchain.Token.getID(); // Reset blockchain to Token from ETH for token cards with zero token balance on it
|
||||
}
|
||||
|
||||
public Date getPersonalizationDateTime() {
|
||||
|
|
@ -434,7 +435,7 @@ public class TangemCard {
|
|||
return failedBalanceRequestCounter.get();
|
||||
}
|
||||
|
||||
Boolean balanceEqual;
|
||||
private Boolean balanceEqual;
|
||||
|
||||
public Boolean isBalanceEqual() {
|
||||
return balanceEqual;
|
||||
|
|
@ -452,22 +453,22 @@ public class TangemCard {
|
|||
|
||||
public Boolean isReusable() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.IsReusable) != 0;
|
||||
return (settingsMask & SettingsMask.IsReusable) != 0;
|
||||
}
|
||||
|
||||
public Boolean allowSwapPIN() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.AllowSwapPIN) != 0;
|
||||
return (settingsMask & SettingsMask.AllowSwapPIN) != 0;
|
||||
}
|
||||
|
||||
public Boolean allowSwapPIN2() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.AllowSwapPIN2) != 0;
|
||||
return (settingsMask & SettingsMask.AllowSwapPIN2) != 0;
|
||||
}
|
||||
|
||||
public Boolean needCVC() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.UseCVC) != 0;
|
||||
return (settingsMask & SettingsMask.UseCVC) != 0;
|
||||
}
|
||||
|
||||
public Boolean useDefaultPIN1() {
|
||||
|
|
@ -476,7 +477,7 @@ public class TangemCard {
|
|||
|
||||
public Boolean useSmartSecurityDelay() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.SmartSecurityDelay) != 0;
|
||||
return (settingsMask & SettingsMask.SmartSecurityDelay) != 0;
|
||||
}
|
||||
|
||||
public enum PIN2_Mode {Unchecked, DefaultPIN2, CustomPIN2}
|
||||
|
|
@ -502,22 +503,22 @@ public class TangemCard {
|
|||
|
||||
public Boolean supportNDEF() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.UseNDEF) != 0;
|
||||
return (settingsMask & SettingsMask.UseNDEF) != 0;
|
||||
}
|
||||
|
||||
public Boolean supportOnlyOneCommandAtTime() {
|
||||
if (settingsMask == null) return null;
|
||||
return supportNDEF() && ((settingsMask.intValue() & SettingsMask.UseOneCommandAtTime) != 0);
|
||||
return supportNDEF() && ((settingsMask & SettingsMask.UseOneCommandAtTime) != 0);
|
||||
}
|
||||
|
||||
public Boolean supportDynamicNDEF() {
|
||||
if (settingsMask == null) return null;
|
||||
return supportNDEF() && ((settingsMask.intValue() & SettingsMask.UseDynamicNDEF) != 0);
|
||||
return supportNDEF() && ((settingsMask & SettingsMask.UseDynamicNDEF) != 0);
|
||||
}
|
||||
|
||||
public Boolean supportBlock() {
|
||||
if (settingsMask == null) return null;
|
||||
return (settingsMask.intValue() & SettingsMask.UseBlock) != 0;
|
||||
return (settingsMask & SettingsMask.UseBlock) != 0;
|
||||
}
|
||||
|
||||
public int getMaxSignatures() {
|
||||
|
|
@ -542,7 +543,7 @@ public class TangemCard {
|
|||
return getFirmwareVersion().endsWith("d") || getFirmwareVersion().endsWith("SDK");
|
||||
}
|
||||
|
||||
public static String getFirmwareVersionNumber(String version) throws Exception {
|
||||
private static String getFirmwareVersionNumber(String version) throws Exception {
|
||||
if (version == null || version.length() < 4) {
|
||||
throw new Exception("Firmware version has unsupported format!");
|
||||
}
|
||||
|
|
@ -555,7 +556,7 @@ public class TangemCard {
|
|||
}
|
||||
}
|
||||
|
||||
public static int[] getFirmwareVersionNumbers(String version) throws Exception {
|
||||
private static int[] getFirmwareVersionNumbers(String version) throws Exception {
|
||||
String fwNumber = getFirmwareVersionNumber(version);
|
||||
String[] strNumbers = fwNumber.split("\\.");
|
||||
|
||||
|
|
@ -651,20 +652,19 @@ public class TangemCard {
|
|||
return B;
|
||||
}
|
||||
|
||||
public void LoadFromBundle(Bundle B) {
|
||||
public void loadFromBundle(Bundle B) {
|
||||
txID = B.getString("txID");
|
||||
Amount = B.getInt("Amount");
|
||||
Height = B.getInt("Height");
|
||||
Raw = B.getString("Raw");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private List<UnspentTransaction> mUnspentTransactions = null;
|
||||
private List<UnspentTransaction> unspentTransactions = null;
|
||||
|
||||
public List<UnspentTransaction> getUnspentTransactions() {
|
||||
if (mUnspentTransactions == null) mUnspentTransactions = new ArrayList<>();
|
||||
return mUnspentTransactions;
|
||||
if (unspentTransactions == null) unspentTransactions = new ArrayList<>();
|
||||
return unspentTransactions;
|
||||
}
|
||||
|
||||
public TangemCard(String UID) {
|
||||
|
|
@ -728,9 +728,9 @@ public class TangemCard {
|
|||
balance = BigDecimal.valueOf(balanceConfirmed + balanceUnconfirmed);
|
||||
} else if (this.getBlockchain() == Blockchain.Ethereum || this.getBlockchain() == Blockchain.EthereumTestNet || this.getBlockchain() == Blockchain.Token) {
|
||||
if (balanceDecimal != null) {
|
||||
balance = new BigDecimal(balanceDecimal); // Returns ETH / token balance
|
||||
balance = new BigDecimal(balanceDecimal); // Returns ETH / token balance
|
||||
} else if (balanceDecimalAlter != null) {
|
||||
balance = new BigDecimal(balanceDecimalAlter); // or ETH balance if there're no tokens on Token card
|
||||
balance = new BigDecimal(balanceDecimalAlter); // or ETH balance if there're no tokens on Token card
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -872,18 +872,18 @@ public class TangemCard {
|
|||
|
||||
public Bundle getAsBundle() {
|
||||
Bundle B = new Bundle();
|
||||
SaveToBundle(B);
|
||||
saveToBundle(B);
|
||||
return B;
|
||||
}
|
||||
|
||||
public void SaveToBundle(Bundle B) {
|
||||
public void saveToBundle(Bundle B) {
|
||||
B.putString("UID", UID);
|
||||
B.putByteArray("CID", CID);
|
||||
B.putString("PIN", PIN);
|
||||
B.putString("PIN2", PIN2.name());
|
||||
B.putString("Status", status.name());
|
||||
B.putString("Blockchain", blockchainID);
|
||||
B.putString("BlockchainName", blochchainName);
|
||||
B.putString("BlockchainName", blockchainName);
|
||||
B.putInt("TokensDecimal", tokensDecimal);
|
||||
B.putString("TokenSymbol", tokenSymbol);
|
||||
B.putString("ContractAddress", contractAddress);
|
||||
|
|
@ -931,10 +931,10 @@ public class TangemCard {
|
|||
B.putBoolean("NeedWriteIssuerData", getNeedWriteIssuerData());
|
||||
}
|
||||
|
||||
if (mUnspentTransactions != null) {
|
||||
if (unspentTransactions != null) {
|
||||
Bundle BB = new Bundle();
|
||||
for (Integer i = 0; i < mUnspentTransactions.size(); i++) {
|
||||
BB.putBundle(i.toString(), mUnspentTransactions.get(i).getAsBundle());
|
||||
for (Integer i = 0; i < unspentTransactions.size(); i++) {
|
||||
BB.putBundle(i.toString(), unspentTransactions.get(i).getAsBundle());
|
||||
}
|
||||
B.putBundle("UnspentTransactions", BB);
|
||||
}
|
||||
|
|
@ -996,7 +996,7 @@ public class TangemCard {
|
|||
tokenSymbol = B.getString("TokenSymbol", "");
|
||||
contractAddress = B.getString("ContractAddress", "");
|
||||
if (B.containsKey("BlockchainName"))
|
||||
blochchainName = B.getString("BlockchainName", "");
|
||||
blockchainName = B.getString("BlockchainName", "");
|
||||
validationNodeDescription = B.getString("validationNodeDescription");
|
||||
if (B.containsKey("dtPersonalization")) {
|
||||
dtPersonalization = new Date(B.getLong("dtPersonalization"));
|
||||
|
|
@ -1023,7 +1023,8 @@ public class TangemCard {
|
|||
if (B.containsKey("FailedBalance"))
|
||||
failedBalanceRequestCounter = new AtomicInteger(B.getInt("FailedBalance"));
|
||||
if (B.containsKey("Issuer")) issuer = Issuer.FindIssuer(B.getString("Issuer"));
|
||||
if (B.containsKey("IssuerPublicDataKey")) issuerPublicDataKey = B.getByteArray("IssuerPublicDataKey");
|
||||
if (B.containsKey("IssuerPublicDataKey"))
|
||||
issuerPublicDataKey = B.getByteArray("IssuerPublicDataKey");
|
||||
|
||||
if (B.containsKey("FirmwareVersion")) firmwareVersion = B.getString("FirmwareVersion");
|
||||
if (B.containsKey("Batch")) batch = B.getString("Batch");
|
||||
|
|
@ -1061,13 +1062,13 @@ public class TangemCard {
|
|||
}
|
||||
|
||||
if (B.containsKey("UnspentTransactions")) {
|
||||
mUnspentTransactions = new ArrayList<>();
|
||||
unspentTransactions = new ArrayList<>();
|
||||
Bundle BB = B.getBundle("UnspentTransactions");
|
||||
Integer i = 0;
|
||||
while (BB.containsKey(i.toString())) {
|
||||
UnspentTransaction t = new UnspentTransaction();
|
||||
t.LoadFromBundle(BB.getBundle(i.toString()));
|
||||
mUnspentTransactions.add(t);
|
||||
t.loadFromBundle(BB.getBundle(i.toString()));
|
||||
unspentTransactions.add(t);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,26 +40,22 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
private var serverApiHelper: ServerApiHelper = ServerApiHelper()
|
||||
private var serverApiHelperElectrum: ServerApiHelperElectrum = ServerApiHelperElectrum()
|
||||
|
||||
var card: TangemCard? = null
|
||||
var feeRequestSuccess = false
|
||||
var balanceRequestSuccess = false
|
||||
var etAmount: EditText? = null
|
||||
var etFee: EditText? = null
|
||||
var rgFee: RadioGroup? = null
|
||||
var progressBar: ProgressBar? = null
|
||||
var btnSend: Button? = null
|
||||
|
||||
var minFee: String? = null
|
||||
var maxFee: String? = null
|
||||
var normalFee: String? = null
|
||||
|
||||
private var card: TangemCard? = null
|
||||
private var feeRequestSuccess = false
|
||||
private var balanceRequestSuccess = false
|
||||
private var etAmount: EditText? = null
|
||||
private var etFee: EditText? = null
|
||||
private var rgFee: RadioGroup? = null
|
||||
private var progressBar: ProgressBar? = null
|
||||
private var btnSend: Button? = null
|
||||
private var minFee: String? = null
|
||||
private var maxFee: String? = null
|
||||
private var normalFee: String? = null
|
||||
private var isIncludeFee: Boolean = true
|
||||
var minFeeInInternalUnits: Long? = 0L
|
||||
private var minFeeInInternalUnits: Long? = 0L
|
||||
private var requestPIN2Count = 0
|
||||
var nodeCheck = false
|
||||
var dtVerified: Date? = null
|
||||
|
||||
|
||||
private var nodeCheck = false
|
||||
private var dtVerified: Date? = null
|
||||
private var calcSize: Int = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -175,7 +171,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
calendar.add(Calendar.MINUTE, -1)
|
||||
|
||||
if (dtVerified == null || dtVerified!!.before(calendar.time)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.the_obtained_data_is_outdated_try_again))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.the_obtained_data_is_outdated_try_again))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
|
|
@ -190,20 +186,20 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
val txAmount = etAmount!!.text.toString()
|
||||
|
||||
if (!engineCoin.hasBalanceInfo(card)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_check_balance_no_connection_with_blockchain_nodes))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_check_balance_no_connection_with_blockchain_nodes))
|
||||
return@setOnClickListener
|
||||
|
||||
} else if (!engineCoin.isBalanceNotZero(card)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.the_wallet_is_empty))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.the_wallet_is_empty))
|
||||
return@setOnClickListener
|
||||
|
||||
} else if (!engineCoin.checkUnspentTransaction(card)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.please_wait_for_confirmation_of_incoming_transaction))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.please_wait_for_confirmation_of_incoming_transaction))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (!engineCoin.checkAmountValue(card, txAmount, txFee, minFeeInInternalUnits, isIncludeFee)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_on_your_card))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_on_your_card))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +231,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_check_balance_no_connection_with_blockchain_nodes))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_check_balance_no_connection_with_blockchain_nodes))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -255,13 +251,13 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
if (fee == BigDecimal.ZERO) {
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_calculate_fee_wrong_data_received_from_node))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_calculate_fee_wrong_data_received_from_node))
|
||||
}
|
||||
|
||||
if (calcSize.toLong() != 0L) {
|
||||
fee = fee.multiply(BigDecimal(calcSize.toLong())).divide(BigDecimal(1024)) // per Kb -> per byte
|
||||
} else {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_calculate_fee_tx_length_unknown))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_calculate_fee_tx_length_unknown))
|
||||
}
|
||||
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
|
|
@ -303,7 +299,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
ServerApiHelper.INFURA_ETH_GAS_PRICE -> {
|
||||
var gasPrice = infuraResponse.result
|
||||
gasPrice = gasPrice.substring(2)
|
||||
// Rounding gas price to integer gwei
|
||||
// rounding gas price to integer gwei
|
||||
val l = BigInteger(gasPrice, 16).divide(BigInteger.valueOf(1000000000L)).multiply(BigInteger.valueOf(1000000000L))
|
||||
|
||||
val m = if (card!!.blockchain == Blockchain.Token) BigInteger.valueOf(60000) else BigInteger.valueOf(21000)
|
||||
|
|
@ -322,11 +318,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
dtVerified = Date()
|
||||
minFeeInInternalUnits = card!!.internalUnitsFromString(normalFeeInGwei)
|
||||
|
||||
Log.i("eth_gas_price", gasPrice)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
// Log.i("eth_gas_price", gasPrice)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -334,11 +326,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
override fun onInfuraFail(method: String, message: String) {
|
||||
when (method) {
|
||||
ServerApiHelper.INFURA_ETH_GAS_PRICE -> {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -347,22 +335,6 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
serverApiHelper.setInfuraResponse(infuraBodyListener)
|
||||
}
|
||||
|
||||
private fun requestElectrum(card: TangemCard, electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelperElectrum.electrumRequestData(card, electrumRequest)
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestInfura(method: String) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelper.infura(method, 67, card!!.wallet, "", "")
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
|
|
@ -427,16 +399,8 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
fun finishActivityWithError(errorCode: Int, message: String) {
|
||||
val intent = Intent()
|
||||
intent.putExtra("message", message)
|
||||
setResult(errorCode, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
// Log.w(getClass().getName(), "Ignore discovered tag!");
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
|
|
@ -461,7 +425,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
fullAmount += unspentOutputs[i].value
|
||||
}
|
||||
|
||||
// Get first unspent
|
||||
// get first unspent
|
||||
val outPut = unspentOutputs[0]
|
||||
val outPutIndex = outPut.outputIndex
|
||||
|
||||
|
|
@ -470,7 +434,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
val fees = FormatUtil.ConvertStringToLong(outFee)
|
||||
var amount = FormatUtil.ConvertStringToLong(outAmount)
|
||||
amount = amount - fees
|
||||
amount -= fees
|
||||
|
||||
val change = fullAmount - fees - amount
|
||||
|
||||
|
|
@ -482,17 +446,14 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
for (i in unspentOutputs.indices) {
|
||||
val newTX = BTCUtils.buildTXForSign(myAddress, outputAddress, myAddress, unspentOutputs, i, amount, change)
|
||||
|
||||
val hashData = Util.calculateSHA256(newTX)
|
||||
val doubleHashData = Util.calculateSHA256(hashData)
|
||||
|
||||
// Log.e("TX_BODY_1", BTCUtils.toHex(newTX));
|
||||
// Log.e("TX_HASH_1", BTCUtils.toHex(hashData));
|
||||
// Log.e("TX_HASH_2", BTCUtils.toHex(doubleHashData));
|
||||
// Log.e("TX_BODY_1", BTCUtils.toHex(newTX))
|
||||
// Log.e("TX_HASH_1", BTCUtils.toHex(hashData))
|
||||
// Log.e("TX_HASH_2", BTCUtils.toHex(doubleHashData))
|
||||
|
||||
unspentOutputs[i].bodyDoubleHash = doubleHashData
|
||||
unspentOutputs[i].bodyHash = hashData
|
||||
|
||||
hashesForSign[i] = doubleHashData
|
||||
}
|
||||
|
||||
|
|
@ -510,26 +471,47 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
return realTX.size
|
||||
}
|
||||
|
||||
fun doSetFee(checkedRadioButtonId: Int) {
|
||||
private fun requestElectrum(card: TangemCard, electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelperElectrum.electrumRequestData(card, electrumRequest)
|
||||
} else
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
|
||||
private fun requestInfura(method: String) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelper.infura(method, 67, card!!.wallet, "", "")
|
||||
} else
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
|
||||
private fun doSetFee(checkedRadioButtonId: Int) {
|
||||
var txtFee = ""
|
||||
when (checkedRadioButtonId) {
|
||||
R.id.rbMinimalFee ->
|
||||
if (minFee != null)
|
||||
txtFee = minFee.toString()
|
||||
else
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
R.id.rbNormalFee ->
|
||||
if (normalFee != null)
|
||||
txtFee = normalFee.toString()
|
||||
else
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
R.id.rbMaximumFee ->
|
||||
if (maxFee != null)
|
||||
txtFee = maxFee.toString()
|
||||
else
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
finishWithError(Activity.RESULT_CANCELED, getString(R.string.cannot_obtain_data_from_blockchain))
|
||||
}
|
||||
etFee!!.setText(txtFee.replace(',', '.'))
|
||||
}
|
||||
|
||||
private fun finishWithError(errorCode: Int, message: String) {
|
||||
val intent = Intent()
|
||||
intent.putExtra("message", message)
|
||||
setResult(errorCode, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -46,8 +46,8 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
tvCardId.text = card!!.cidDescription
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
tvIssuer.text = card!!.issuerDescription
|
||||
//tvBlockchain.text = card!!.blockchainName
|
||||
|
|
|
|||
|
|
@ -147,12 +147,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
// set listeners
|
||||
fab.setOnClickListener { showMenu(it) }
|
||||
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// fab.setOnLongClickListener {
|
||||
// startActivity(Intent(this, SettingsDebugActivity::class.java))
|
||||
// false
|
||||
// }
|
||||
// }
|
||||
|
||||
val apiHelper = ServerApiHelper()
|
||||
apiHelper.setLastVersionListener { response ->
|
||||
|
|
@ -315,7 +309,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
val cardInfo = Bundle()
|
||||
cardInfo.putString("UID", cardProtocol.card.uid)
|
||||
val bCard = Bundle()
|
||||
cardProtocol.card.SaveToBundle(bCard)
|
||||
cardProtocol.card.saveToBundle(bCard)
|
||||
cardInfo.putBundle("Card", bCard)
|
||||
|
||||
val uid = cardInfo.getString("UID")
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
else if (mode == Mode.ConfirmNewPIN2)
|
||||
tvPinPrompt.setText(R.string.confirm_new_pin_2)
|
||||
else if (mode == Mode.RequestPIN2) {
|
||||
val uid = intent.getStringExtra("UID")
|
||||
val mCard = TangemCard(uid)
|
||||
mCard.loadFromBundle(intent.getBundleExtra("Card"))
|
||||
val uid = intent.getStringExtra(TangemCard.EXTRA_UID)
|
||||
val card = TangemCard(uid)
|
||||
card.loadFromBundle(intent.getBundleExtra(TangemCard.EXTRA_CARD))
|
||||
|
||||
if (mCard.PIN2 == TangemCard.PIN2_Mode.DefaultPIN2 || mCard.PIN2 == TangemCard.PIN2_Mode.Unchecked) {
|
||||
if (card.PIN2 == TangemCard.PIN2_Mode.DefaultPIN2 || card.PIN2 == TangemCard.PIN2_Mode.Unchecked) {
|
||||
// if we know PIN2 or not try default previously - use it
|
||||
PINStorage.setPIN2(PINStorage.getDefaultPIN2())
|
||||
setResult(Activity.RESULT_OK)
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
newPIN = intent.getStringExtra("newPIN")
|
||||
newPIN2 = intent.getStringExtra("newPIN2")
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ class PrepareCryptonitOtherAPIWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
cryptonit = Cryptonit_OtherAPI(this)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
cryptonit = Cryptonit(this)
|
||||
|
||||
|
|
@ -70,12 +70,12 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
tvFeeCurrency.text = tvCurrency.text
|
||||
|
||||
etAmount.setText(engine.convertByteArrayToAmount(card!!, card!!.denomination))
|
||||
etAmount.setOnEditorActionListener{lv,actionId,event->
|
||||
etAmount.setOnEditorActionListener { lv, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
val imm = lv.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(lv.windowToken, 0)
|
||||
true
|
||||
}else {
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
val strFee: String = etFee.text.toString().replace(",", ".")
|
||||
var dblAmount: Double = strAmount.toDouble()
|
||||
var dblFee: Double = strFee.toDouble()
|
||||
cryptonit!!.fee=strFee
|
||||
cryptonit!!.fee = strFee
|
||||
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.cryptonit_request_withdrawal)
|
||||
|
|
@ -116,8 +116,8 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
}
|
||||
|
||||
ivRefreshBalance.setOnClickListener {
|
||||
cryptonit!!.username=etUsername.text.toString()
|
||||
cryptonit!!.password=etPassword.text.toString()
|
||||
cryptonit!!.username = etUsername.text.toString()
|
||||
cryptonit!!.password = etPassword.text.toString()
|
||||
cryptonit!!.saveAccountInfo()
|
||||
doRequestBalance()
|
||||
}
|
||||
|
|
@ -137,11 +137,10 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
}
|
||||
cryptonit!!.setWithdrawalListener { response ->
|
||||
rlProgressBar.visibility = View.INVISIBLE
|
||||
if (response.success != null && response.success!!){
|
||||
Toast.makeText(this,"Withdrawal successful!", Toast.LENGTH_LONG).show();
|
||||
if (response.success != null && response.success!!) {
|
||||
Toast.makeText(this, "Withdrawal successful!", Toast.LENGTH_LONG).show();
|
||||
finish()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tvError.visibility = View.VISIBLE
|
||||
tvError.text = response.errors.toString()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
kraken = Kraken(this)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
tvCardID.text = card!!.cidDescription
|
||||
val engine = CoinEngineFactory.create(card!!.blockchain)
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
tvCardID.text = card!!.cidDescription
|
||||
progressBar.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
|
|
|
|||
|
|
@ -5,13 +5,12 @@ import android.nfc.NfcAdapter
|
|||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.widget.Toast
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.ServerApiHelperElectrum
|
||||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.Blockchain
|
||||
import com.tangem.domain.wallet.CoinEngineFactory
|
||||
|
|
@ -25,15 +24,13 @@ import java.math.BigInteger
|
|||
class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
const val EXTRA_UID: String = "UID"
|
||||
const val EXTRA_CARD: String = "Card"
|
||||
const val EXTRA_TX: String = "TX"
|
||||
}
|
||||
|
||||
private var serverApiHelper: ServerApiHelper = ServerApiHelper()
|
||||
private var serverApiHelperElectrum: ServerApiHelperElectrum = ServerApiHelperElectrum()
|
||||
|
||||
var card: TangemCard? = null
|
||||
private var card: TangemCard? = null
|
||||
private var tx: String? = null
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
|
|
@ -46,8 +43,8 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
nfcManager = NfcManager(this, this)
|
||||
|
||||
val intent = intent
|
||||
card = TangemCard(getIntent().getStringExtra(EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(EXTRA_CARD))
|
||||
card = TangemCard(getIntent().getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
tx = intent.getStringExtra(EXTRA_TX)
|
||||
|
||||
val engine = CoinEngineFactory.create(card!!.blockchain)
|
||||
|
|
@ -70,29 +67,26 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
if (electrumRequest!!.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
try {
|
||||
var hashTX = electrumRequest.resultString
|
||||
|
||||
try {
|
||||
if (hashTX.startsWith("0x") || hashTX.startsWith("0X")) {
|
||||
hashTX = hashTX.substring(2)
|
||||
}
|
||||
Log.e("TX_RESULT", hashTX)
|
||||
finishWithSuccess()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
// finishWithError(hashTX)
|
||||
finishWithError(hashTX)
|
||||
requestElectrum(card!!, ElectrumRequest.broadcast(card!!.wallet, tx))
|
||||
}
|
||||
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
// finishWithError(e.toString())
|
||||
finishWithError(e.toString())
|
||||
requestElectrum(card!!, ElectrumRequest.broadcast(card!!.wallet, tx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onElectrumFail(message: String?) {
|
||||
|
||||
finishWithError(message!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +103,7 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
val tmp = infuraResponse.result
|
||||
hashTX = tmp
|
||||
} catch (e: JSONException) {
|
||||
finishWithError(e.message!!)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -119,18 +114,13 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
val nonce = card!!.confirmedTXCount
|
||||
nonce.add(BigInteger.valueOf(1))
|
||||
card!!.confirmedTXCount = nonce
|
||||
// Log.e("TX_RESULT", hashTX)
|
||||
|
||||
finishWithSuccess()
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
finishWithError(e.message!!)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,10 +129,6 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
ServerApiHelper.INFURA_ETH_SEND_RAW_TRANSACTION -> {
|
||||
finishWithError(message)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -160,36 +146,6 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
private fun requestInfura(method: String, contract: String) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelper.infura(method, 67, card!!.wallet, contract, tx)
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestElectrum(card: TangemCard, electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelperElectrum.electrumRequestData(card, electrumRequest)
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun finishWithError(message: String) {
|
||||
val intent = Intent()
|
||||
intent.putExtra("message", String.format(getString(R.string.try_again_failed_to_send_transaction), message))
|
||||
setResult(RESULT_CANCELED, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
fun finishWithSuccess() {
|
||||
val intent = Intent()
|
||||
intent.putExtra("message", getString(R.string.transaction_has_been_successfully_signed))
|
||||
setResult(RESULT_OK, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
|
|
@ -207,12 +163,38 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
// Log.w(javaClass.name, "Ignore discovered tag!")
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestInfura(method: String, contract: String) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelper.infura(method, 67, card!!.wallet, contract, tx)
|
||||
} else
|
||||
finishWithError(getString(R.string.no_connection))
|
||||
}
|
||||
|
||||
private fun requestElectrum(card: TangemCard, electrumRequest: ElectrumRequest) {
|
||||
if (UtilHelper.isOnline(this)) {
|
||||
serverApiHelperElectrum.electrumRequestData(card, electrumRequest)
|
||||
} else
|
||||
finishWithError(getString(R.string.no_connection))
|
||||
}
|
||||
|
||||
private fun finishWithSuccess() {
|
||||
val intent = Intent()
|
||||
intent.putExtra("message", getString(R.string.transaction_has_been_successfully_signed))
|
||||
setResult(RESULT_OK, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun finishWithError(message: String) {
|
||||
val intent = Intent()
|
||||
intent.putExtra("message", String.format(getString(R.string.try_again_failed_to_send_transaction), message))
|
||||
setResult(RESULT_CANCELED, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.support.v7.widget.Toolbar
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
class SettingsDebugActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings_debug)
|
||||
|
||||
initToolbar()
|
||||
}
|
||||
|
||||
private fun initToolbar() {
|
||||
val toolbar = findViewById<Toolbar>(R.id.toolbar)!!
|
||||
toolbar.title = getString(R.string.debug_settings)
|
||||
setSupportActionBar(toolbar)
|
||||
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp)
|
||||
toolbar.setNavigationOnClickListener {
|
||||
if (fragmentManager.backStackEntryCount == 0)
|
||||
finish()
|
||||
else
|
||||
fragmentManager.popBackStack()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -54,8 +54,8 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
card = TangemCard(intent.getStringExtra("UID"))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle("Card"))
|
||||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
amountStr = intent.getStringExtra(EXTRA_AMOUNT)
|
||||
feeStr = intent.getStringExtra("Fee")
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.presentation.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceFragment
|
||||
import android.preference.SwitchPreference
|
||||
import com.tangem.wallet.R
|
||||
|
||||
class SettingsDebug : PreferenceFragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
addPreferencesFromResource(R.xml.fr_settings_debug)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/activity_about_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/about_fragment"
|
||||
android:name="com.tangem.presentation.fragment.SettingsDebug"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/view"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory android:title="">
|
||||
<SwitchPreference
|
||||
android:key="debug_switch_1"
|
||||
android:summary="" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="debug_switch_2"
|
||||
android:summary="" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
Loading…
Add table
Add a link
Reference in a new issue