Updated on 2026-08-14
This commit is contained in:
parent
36d478fbc9
commit
4b325b213b
34 changed files with 1257 additions and 1132 deletions
|
|
@ -99,17 +99,17 @@
|
|||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tangem.presentation.activity.PreparePaymentActivity"
|
||||
android:name="com.tangem.presentation.activity.PrepareTransactionActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tangem.presentation.activity.ConfirmPaymentActivity"
|
||||
android:name="com.tangem.presentation.activity.ConfirmTransactionActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tangem.presentation.activity.SignPaymentActivity"
|
||||
android:name="com.tangem.presentation.activity.SignTransactionActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ object Constant {
|
|||
const val EXTRA_MODIFICATION_UPDATE = "update"
|
||||
|
||||
// LoadedWallet, VerifyCard
|
||||
const val REQUEST_CODE_SEND_PAYMENT = 1
|
||||
const val REQUEST_CODE_SEND_TRANSACTION = 1
|
||||
const val REQUEST_CODE_PURGE = 2
|
||||
const val REQUEST_CODE_REQUEST_PIN2_FOR_PURGE = 3
|
||||
const val REQUEST_CODE_VERIFY_CARD = 4
|
||||
|
|
@ -21,7 +21,7 @@ object Constant {
|
|||
const val REQUEST_CODE_ENTER_NEW_PIN2 = 6
|
||||
const val REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7
|
||||
const val REQUEST_CODE_SWAP_PIN = 8
|
||||
const val REQUEST_CODE_RECEIVE_PAYMENT = 9
|
||||
const val REQUEST_CODE_RECEIVE_TRANSACTION = 9
|
||||
|
||||
// MainActivity
|
||||
const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
|
|
@ -57,26 +57,26 @@ object Constant {
|
|||
const val REQUEST_CODE_CREATE_NEW_WALLET_ACTIVITY = 2
|
||||
const val REQUEST_CODE_REQUEST_PIN2 = 3
|
||||
|
||||
// ConfirmPaymentActivity
|
||||
const val REQUEST_CODE_SIGN_PAYMENT = 1
|
||||
// ConfirmTransactionActivity
|
||||
const val REQUEST_CODE_SIGN_TRANSACTION = 1
|
||||
const val REQUEST_CODE_REQUEST_PIN2_ = 2
|
||||
|
||||
// SendTransactionActivity
|
||||
const val EXTRA_TX: String = "TX"
|
||||
|
||||
// SignPaymentActivity
|
||||
// SignTransactionActivity
|
||||
const val EXTRA_AMOUNT = "Amount"
|
||||
const val EXTRA_AMOUNT_CURRENCY = "AmountCurrency"
|
||||
const val EXTRA_FEE = "Fee"
|
||||
const val EXTRA_FEE_CURRENCY = "FeeCurrency"
|
||||
const val EXTRA_FEE_INCLUDED = "FeeIncluded"
|
||||
const val EXTRA_TARGET_ADDRESS = "TargetAddress"
|
||||
const val REQUEST_CODE_SEND_PAYMENT_ = 1
|
||||
const val REQUEST_CODE_SEND_TRANSACTION_ = 1
|
||||
const val RESULT_INVALID_PIN_ = Activity.RESULT_FIRST_USER
|
||||
|
||||
// PreparePaymentActivity
|
||||
// PrepareTransactionActivity
|
||||
const val REQUEST_CODE_SCAN_QR = 1
|
||||
const val REQUEST_CODE_SEND_PAYMENT__ = 2
|
||||
const val REQUEST_CODE_SEND_TRANSACTION__ = 2
|
||||
|
||||
// PrepareCryptonitOtherApiWithdrawalActivity
|
||||
const val REQUEST_CODE_SCAN_QR_KEY = 1
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ public class ServerApiCommon {
|
|||
public static final int ESTIMATE_FEE_PRIORITY = 2;
|
||||
public static final int ESTIMATE_FEE_NORMAL = 3;
|
||||
public static final int ESTIMATE_FEE_MINIMAL = 6;
|
||||
private EstimateFeeListener estimateFeeListener;
|
||||
private EstimatedFeeListener estimatedFeeListener;
|
||||
|
||||
public interface EstimateFeeListener {
|
||||
public interface EstimatedFeeListener {
|
||||
void onSuccess(int blockCount, String estimateFeeResponse);
|
||||
void onFail(int blockCount, String message);
|
||||
}
|
||||
|
||||
public void setEstimateFee(EstimateFeeListener listener) {
|
||||
estimateFeeListener = listener;
|
||||
public void setBtcEstimatedFeeListener(EstimatedFeeListener listener) {
|
||||
estimatedFeeListener = listener;
|
||||
}
|
||||
|
||||
public void estimateFee(int blockCount) {
|
||||
public void requestBtcEstimatedFee(int blockCount) {
|
||||
EstimatefeeApi estimatefeeApi = App.getNetworkComponent().getRetrofitEstimatefee().create(EstimatefeeApi.class);
|
||||
|
||||
Call<String> call;
|
||||
|
|
@ -60,17 +60,17 @@ public class ServerApiCommon {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.code() == 200) {
|
||||
estimateFeeListener.onSuccess(blockCount, response.body());
|
||||
Log.i(TAG, "estimateFee onResponse " + response.code() + " " + response.body());
|
||||
estimatedFeeListener.onSuccess(blockCount, response.body());
|
||||
Log.i(TAG, "requestBtcEstimatedFee onResponse " + response.code() + " " + response.body());
|
||||
} else
|
||||
estimateFeeListener.onFail(blockCount, response.body());
|
||||
Log.e(TAG, "estimateFee onResponse " + response.code());
|
||||
estimatedFeeListener.onFail(blockCount, response.body());
|
||||
Log.e(TAG, "requestBtcEstimatedFee onResponse " + response.code());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
estimateFeeListener.onFail(blockCount, t.getMessage());
|
||||
Log.e(TAG, "estimateFee onFailure " + t.getMessage());
|
||||
estimatedFeeListener.onFail(blockCount, t.getMessage());
|
||||
Log.e(TAG, "requestBtcEstimatedFee onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -79,18 +79,18 @@ public class ServerApiCommon {
|
|||
* HTTP
|
||||
* Used in Crypto-currency course
|
||||
*/
|
||||
private RateInfoDataListener rateInfoDataListener;
|
||||
private RateInfoListener rateInfoListener;
|
||||
|
||||
public interface RateInfoDataListener {
|
||||
public interface RateInfoListener {
|
||||
void onSuccess(RateInfoResponse rateInfoResponse);
|
||||
}
|
||||
|
||||
public void setRateInfoData(RateInfoDataListener listener) {
|
||||
rateInfoDataListener = listener;
|
||||
public void setRateInfoListener(RateInfoListener listener) {
|
||||
rateInfoListener = listener;
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void rateInfoData(String cryptoId) {
|
||||
public void requestRateInfo(String cryptoId) {
|
||||
CoinmarketApi coinmarketApi = App.getNetworkComponent().getRetrofitCoinmarketcap().create(CoinmarketApi.class);
|
||||
|
||||
coinmarketApi.getRateInfoList()
|
||||
|
|
@ -100,12 +100,12 @@ public class ServerApiCommon {
|
|||
if (!rateInfoModelList.isEmpty()) {
|
||||
for (RateInfoResponse rateInfoMode : rateInfoModelList) {
|
||||
if (rateInfoMode.getId().equals(cryptoId)) {
|
||||
rateInfoDataListener.onSuccess(rateInfoMode);
|
||||
Log.i(TAG, "rateInfoData " + cryptoId + " onResponse " + "200");
|
||||
rateInfoListener.onSuccess(rateInfoMode);
|
||||
Log.i(TAG, "requestRateInfo " + cryptoId + " onResponse " + "200");
|
||||
}
|
||||
}
|
||||
} else
|
||||
Log.e(TAG, "rateInfoData " + cryptoId + " onResponse " + "Empty");
|
||||
Log.e(TAG, "requestRateInfo " + cryptoId + " onResponse " + "Empty");
|
||||
},
|
||||
// handle error
|
||||
Throwable::printStackTrace);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import com.tangem.domain.wallet.bch.BitcoinCashNode;
|
|||
import com.tangem.domain.wallet.btc.BitcoinNode;
|
||||
import com.tangem.domain.wallet.btc.BitcoinNodeTestNet;
|
||||
import com.tangem.domain.wallet.ltc.LitecoinNode;
|
||||
import com.tangem.tangemcard.reader.CardProtocol;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -24,7 +23,6 @@ import java.net.InetSocketAddress;
|
|||
import java.net.Socket;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -47,13 +45,13 @@ import io.reactivex.schedulers.Schedulers;
|
|||
/**
|
||||
* Request processor for Electrum Api
|
||||
* Every request live cycle:
|
||||
* 1. In application create request and call {@link ServerApiElectrum}.electrumRequestData(..)
|
||||
* 1. In application create request and call {@link ServerApiElectrum}.requestData(..)
|
||||
* 2. Try send every request for max 4 times,
|
||||
* 3. If all 4 times fail call DefaultObserver<ElectrumRequest>.onError (defined in .electrumRequestData(..)) and than
|
||||
* {@link ElectrumRequestDataListener}.onFail(...) callback
|
||||
* 3. If all 4 times fail call DefaultObserver<ElectrumRequest>.onError (defined in .requestData(..)) and than
|
||||
* {@link ResponseListener}.onFail(...) callback
|
||||
* Error can be acquired with {@link ElectrumRequest}.getError() method
|
||||
* 4. If request network communication finished successfully then call DefaultObserver<ElectrumRequest>.onComplete (defined in .electrumRequestData) and than
|
||||
* {@link ElectrumRequestDataListener}.onSuccess(...) callback
|
||||
* 4. If request network communication finished successfully then call DefaultObserver<ElectrumRequest>.onComplete (defined in .requestData) and than
|
||||
* {@link ResponseListener}.onSuccess(...) callback
|
||||
*/
|
||||
public class ServerApiElectrum {
|
||||
private static String TAG = ServerApiElectrum.class.getSimpleName();
|
||||
|
|
@ -62,7 +60,7 @@ public class ServerApiElectrum {
|
|||
* TCP, SSL
|
||||
* Used in BTC, BCH
|
||||
*/
|
||||
private ElectrumRequestDataListener electrumRequestDataListener;
|
||||
private ResponseListener responseListener;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
|
|
@ -76,7 +74,7 @@ public class ServerApiElectrum {
|
|||
/**
|
||||
* Interface for notification every request result
|
||||
*/
|
||||
public interface ElectrumRequestDataListener {
|
||||
public interface ResponseListener {
|
||||
|
||||
/**
|
||||
* Notify that request processing was successful
|
||||
|
|
@ -94,8 +92,8 @@ public class ServerApiElectrum {
|
|||
* Set notificaion listener
|
||||
* @param listener
|
||||
*/
|
||||
public void setElectrumRequestData(ElectrumRequestDataListener listener) {
|
||||
electrumRequestDataListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -104,7 +102,7 @@ public class ServerApiElectrum {
|
|||
* @param ctx
|
||||
* @param electrumRequest
|
||||
*/
|
||||
public void electrumRequestData(TangemContext ctx, ElectrumRequest electrumRequest) {
|
||||
public void requestData(TangemContext ctx, ElectrumRequest electrumRequest) {
|
||||
requestsCount++;
|
||||
Log.i(TAG, String.format("New request[%d]: %s", requestsCount,electrumRequest.getMethod()));
|
||||
Observable<ElectrumRequest> checkElectrumDataObserver = Observable.just(electrumRequest)
|
||||
|
|
@ -129,20 +127,20 @@ public class ServerApiElectrum {
|
|||
@Override
|
||||
public void onNext(ElectrumRequest v) {
|
||||
if (electrumRequest.answerData != null) {
|
||||
Log.i(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onNext != null");
|
||||
Log.i(TAG, "requestData " + electrumRequest.getMethod() + " onNext != null");
|
||||
} else {
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onNext == null");
|
||||
Log.e(TAG, "requestData " + electrumRequest.getMethod() + " onNext == null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
requestsCount--;
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onError " + e.getMessage());
|
||||
Log.e(TAG, "requestData " + electrumRequest.getMethod() + " onError " + e.getMessage());
|
||||
Log.e(TAG, String.format("%d requests left in processing",requestsCount));
|
||||
electrumRequest.setError(ctx.getString(R.string.cannot_obtain_data_from_blockchain));
|
||||
//setErrorOccurred(e.getMessage());//;
|
||||
electrumRequestDataListener.onFail(electrumRequest);
|
||||
responseListener.onFail(electrumRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,16 +150,16 @@ public class ServerApiElectrum {
|
|||
public void onComplete() {
|
||||
requestsCount--;
|
||||
if (electrumRequest.answerData != null) {
|
||||
Log.i(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onComplete, answerData!=null");
|
||||
Log.i(TAG, "requestData " + electrumRequest.getMethod() + " onComplete, answerData!=null");
|
||||
} else {
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onComplete, answerData==null");
|
||||
Log.e(TAG, "requestData " + electrumRequest.getMethod() + " onComplete, answerData==null");
|
||||
}
|
||||
Log.e(TAG, String.format("%d requests left in processing",requestsCount));
|
||||
if (electrumRequest.answerData != null && electrumRequest.getError()==null) {
|
||||
electrumRequestDataListener.onSuccess(electrumRequest);
|
||||
responseListener.onSuccess(electrumRequest);
|
||||
} else {
|
||||
// if( error==null || error.isEmpty() ) setErrorOccurred(ctx.getString(R.string.cannot_obtain_data_from_blockchain));
|
||||
electrumRequestDataListener.onFail(electrumRequest);
|
||||
responseListener.onFail(electrumRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +255,7 @@ public class ServerApiElectrum {
|
|||
|
||||
} catch (ConnectException e) {
|
||||
//e.printStackTrace();
|
||||
//electrumRequestDataListener.onFail(e.getMessage());
|
||||
//responseListener.onFail(e.getMessage());
|
||||
electrumRequest.setError(App.getInstance().getString(R.string.cannot_obtain_data_from_blockchain_no_connection));
|
||||
Log.e(TAG, "doElectrumRequestTcp " + electrumRequest.getMethod() + " ConnectException " + e.getMessage());
|
||||
} finally {
|
||||
|
|
@ -274,7 +272,7 @@ public class ServerApiElectrum {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
//electrumRequestDataListener.onFail(e.getMessage());
|
||||
//responseListener.onFail(e.getMessage());
|
||||
electrumRequest.setError(App.getInstance().getString(R.string.cannot_obtain_data_from_blockchain_communication_error));
|
||||
Log.e(TAG, "doElectrumRequestTcp " + electrumRequest.getMethod() + " IOException " + e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ public class ServerApiInfura {
|
|||
return requestsCount <= 0;
|
||||
}
|
||||
|
||||
private InfuraBodyListener infuraBodyListener;
|
||||
private ResponseListener responseListener;
|
||||
|
||||
public interface InfuraBodyListener {
|
||||
public interface ResponseListener {
|
||||
void onSuccess(String method, InfuraResponse infuraResponse);
|
||||
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
||||
public void setInfuraResponse(InfuraBodyListener listener) {
|
||||
infuraBodyListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void infura(String method, int id, String wallet, String contract, String tx) {
|
||||
public void requestData(String method, int id, String wallet, String contract, String tx) {
|
||||
requestsCount++;
|
||||
InfuraApi infuraApi = App.getNetworkComponent().getRetrofitInfura().create(InfuraApi.class);
|
||||
|
||||
|
|
@ -86,18 +86,18 @@ public class ServerApiInfura {
|
|||
public void onResponse(@NonNull Call<InfuraResponse> call, @NonNull Response<InfuraResponse> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
infuraBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "infura " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
infuraBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "infura " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InfuraResponse> call, @NonNull Throwable t) {
|
||||
infuraBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "infura " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,21 +32,21 @@ public class ServerApiInsight {
|
|||
return requestsCount <= 0;
|
||||
}
|
||||
|
||||
private InsightBodyListener insightBodyListener;
|
||||
private ResponseListener responseListener;
|
||||
|
||||
public interface InsightBodyListener {
|
||||
public interface ResponseListener {
|
||||
void onSuccess(String method, InsightResponse insightResponse);
|
||||
void onSuccess(String method, List<InsightResponse> utxoList);
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
||||
public void setInsightResponse(InsightBodyListener listener) {
|
||||
insightBodyListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void insight(String method, String wallet, String tx) {
|
||||
public void requestData(String method, String wallet, String tx) {
|
||||
requestsCount++;
|
||||
String insightURL = "http://130.185.109.17:3001/insight-api"; //TODO: make random selection
|
||||
String insightURL = "http://130.185.109.17:3001/requestData-api"; //TODO: make random selection
|
||||
this.lastNode = insightURL; //TODO: show node instead of URL
|
||||
|
||||
Retrofit retrofitInsight = new Retrofit.Builder() //TODO: move to NetworkModule+NetworkComponent if possible
|
||||
|
|
@ -64,18 +64,18 @@ public class ServerApiInsight {
|
|||
public void onResponse(@NonNull Call<List<InsightResponse>> call, @NonNull Response<List<InsightResponse>> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
insightBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
insightBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<InsightResponse>> call, @NonNull Throwable t) {
|
||||
insightBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "insight " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -112,18 +112,18 @@ public class ServerApiInsight {
|
|||
public void onResponse(@NonNull Call<InsightResponse> call, @NonNull Response<InsightResponse> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
insightBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
insightBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "insight " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InsightResponse> call, @NonNull Throwable t) {
|
||||
insightBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "insight " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ public class ServerApiRootstock {
|
|||
return requestsCount <= 0;
|
||||
}
|
||||
|
||||
private RootstockBodyListener rootstockBodyListener;
|
||||
private ResponseListener responseListener;
|
||||
|
||||
public interface RootstockBodyListener {
|
||||
public interface ResponseListener {
|
||||
void onSuccess(String method, InfuraResponse infuraResponse);
|
||||
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
||||
public void setRootstockResponse(RootstockBodyListener listener) {
|
||||
rootstockBodyListener = listener;
|
||||
public void setResponseListener(ResponseListener listener) {
|
||||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void rootstock(String method, int id, String wallet, String contract, String tx) {
|
||||
public void requestData(String method, int id, String wallet, String contract, String tx) {
|
||||
requestsCount++;
|
||||
RootstockApi rootstockApi = App.getNetworkComponent().getRetrofitRootstock().create(RootstockApi.class);
|
||||
|
||||
|
|
@ -86,18 +86,18 @@ public class ServerApiRootstock {
|
|||
public void onResponse(@NonNull Call<InfuraResponse> call, @NonNull Response<InfuraResponse> response) {
|
||||
if (response.code() == 200) {
|
||||
requestsCount--;
|
||||
rootstockBodyListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "rootstock " + method + " onResponse " + response.code());
|
||||
responseListener.onSuccess(method, response.body());
|
||||
Log.i(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
} else {
|
||||
rootstockBodyListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "rootstock " + method + " onResponse " + response.code());
|
||||
responseListener.onFail(method, String.valueOf(response.code()));
|
||||
Log.e(TAG, "requestData " + method + " onResponse " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<InfuraResponse> call, @NonNull Throwable t) {
|
||||
rootstockBodyListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "rootstock " + method + " onFailure " + t.getMessage());
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.data.network;
|
|||
class ServerURL {
|
||||
static final String API_TANGEM = "https://verify.tangem.com/";
|
||||
static final String API_COINMARKETCAP = "https://api.coinmarketcap.com/";
|
||||
static final String API_INFURA = "https://mainnet.infura.io/";
|
||||
static final String API_INFURA = "https://mainnet.requestData.io/";
|
||||
static final String API_ESTIMATEFEE = "https://estimatefee.com/";
|
||||
static final String API_UPDATE_VERSION = "https://raw.githubusercontent.com/";
|
||||
static final String API_ROOTSTOCK = "https://public-node.rsk.co/";
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ class Navigator {
|
|||
context.startActivityForResult(PurgeActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_PURGE)
|
||||
}
|
||||
|
||||
fun showPreparePayment(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(PreparePaymentActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_SEND_PAYMENT)
|
||||
fun showPrepareTransaction(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(PrepareTransactionActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_SEND_TRANSACTION)
|
||||
}
|
||||
|
||||
fun showCreateNewWallet(context: Activity, ctx: TangemContext) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.tangem.presentation.activity.LogoActivity;
|
|||
import com.tangem.presentation.activity.MainActivity;
|
||||
import com.tangem.presentation.activity.PrepareCryptonitOtherApiWithdrawalActivity;
|
||||
import com.tangem.presentation.activity.PrepareKrakenWithdrawalActivity;
|
||||
import com.tangem.presentation.activity.PreparePaymentActivity;
|
||||
import com.tangem.presentation.activity.PrepareTransactionActivity;
|
||||
import com.tangem.presentation.activity.VerifyCardActivity;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
|
@ -23,7 +23,7 @@ public interface NavigatorComponent {
|
|||
|
||||
void inject(MainActivity activity);
|
||||
|
||||
void inject(PreparePaymentActivity activity);
|
||||
void inject(PrepareTransactionActivity activity);
|
||||
|
||||
void inject(PrepareCryptonitOtherApiWithdrawalActivity activity);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,12 +181,10 @@ public abstract class CoinEngine {
|
|||
|
||||
public abstract boolean isBalanceNotZero();
|
||||
|
||||
// public abstract byte[] sign(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress, CardProtocol protocol) throws Exception;
|
||||
|
||||
// TODO - change isExtractPossible to isExtractPossible and if not - return string message
|
||||
// TODO - return string message
|
||||
public abstract boolean isExtractPossible();
|
||||
|
||||
public abstract Uri getShareWalletUriExplorer();
|
||||
public abstract Uri getWalletExplorerUri();
|
||||
|
||||
public abstract Uri getShareWalletUri();
|
||||
|
||||
|
|
@ -245,14 +243,14 @@ public abstract class CoinEngine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create instance of {@link SignTask.PaymentToSign} used for transaction signing and sending
|
||||
* Create instance of {@link SignTask.TransactionToSign} used for transaction signing and sending
|
||||
*
|
||||
* Transaction processing sequence:
|
||||
* 1. User enter transaction attributes
|
||||
* 2. Application create instance of {@link SignTask.PaymentToSign} by call {@see constructPayment}
|
||||
* 3. Application set notification when transaction were prepared {@see setOnNeedSendPayment} and start {@link SignTask}
|
||||
* 2. Application create instance of {@link SignTask.TransactionToSign} by call {@see constructTransaction}
|
||||
* 3. Application set notification when transaction were prepared {@see setOnNeedSendTransaction} and start {@link SignTask}
|
||||
* 4. User tap card and card sign transaction
|
||||
* 5. Application receive {@link CoinEngine.OnNeedSendPayment} notification with prepared raw transaction
|
||||
* 5. Application receive {@link OnNeedSendTransaction} notification with prepared raw transaction
|
||||
* 6. Application show user information that transaction ready for sending and start sending procedure by call {@see requestSendTransaction}
|
||||
* 7. Application receive notification of sending result through {@link CoinEngine.BlockchainRequestsCallbacks} and show result to user
|
||||
*
|
||||
|
|
@ -260,32 +258,32 @@ public abstract class CoinEngine {
|
|||
* @param feeValue - fee amount of desired transaction
|
||||
* @param IncFee - true if fee amount is included in amountValue (amountValue is total amount of transaction)
|
||||
* @param targetAddress - target address of transaction
|
||||
* @return instance of {@link SignTask.PaymentToSign}
|
||||
* @return instance of {@link SignTask.TransactionToSign}
|
||||
* @throws Exception if something goes wrong
|
||||
*/
|
||||
public abstract SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception;
|
||||
public abstract SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception;
|
||||
|
||||
/**
|
||||
* Interface used to notify main application when new transaction is prepared to send
|
||||
*/
|
||||
public interface OnNeedSendPayment {
|
||||
void onPaymentPrepared(byte[] txForSend);
|
||||
public interface OnNeedSendTransaction {
|
||||
void onTransactionPrepared(byte[] txForSend);
|
||||
}
|
||||
|
||||
protected OnNeedSendPayment onNeedSendPayment;
|
||||
protected OnNeedSendTransaction onNeedSendTransaction;
|
||||
|
||||
|
||||
/**
|
||||
* Set notification callback when new transaction is prepared to send
|
||||
*/
|
||||
public void setOnNeedSendPayment(OnNeedSendPayment onNeedSendPayment) {
|
||||
this.onNeedSendPayment = onNeedSendPayment;
|
||||
public void setOnNeedSendTransaction(OnNeedSendTransaction onNeedSendTransaction) {
|
||||
this.onNeedSendTransaction = onNeedSendTransaction;
|
||||
}
|
||||
|
||||
protected void notifyOnNeedSendPayment(byte[] txForSend) throws Exception {
|
||||
if (onNeedSendPayment == null)
|
||||
throw new Exception("Payment signed but no callback defined to send!");
|
||||
onNeedSendPayment.onPaymentPrepared(txForSend);
|
||||
protected void notifyOnNeedSendTransaction(byte[] txForSend) throws Exception {
|
||||
if (onNeedSendTransaction == null)
|
||||
throw new Exception("Transaction was signed but no callback defined to send!");
|
||||
onNeedSendTransaction.onTransactionPrepared(txForSend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://bch.btc.com/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
checkBlockchainDataExists();
|
||||
|
||||
String srcLegacyAddress = convertToLegacyAddress(ctx.getCoinData().getWallet());
|
||||
|
|
@ -500,7 +500,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -551,7 +551,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
byte[] txForSend = BCHUtils.buildTXForSend(destLegacyAddress, srcLegacyAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -561,7 +561,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) throws Exception {
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumBodyListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumBodyListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.isMethod(ElectrumRequest.METHOD_GetBalance)) {
|
||||
|
|
@ -606,7 +606,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
String hash = jsUnspent.getString("tx_hash");
|
||||
if (height != -1) {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -649,22 +649,22 @@ public class BtcCashEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener);
|
||||
serverApiElectrum.setResponseListener(electrumBodyListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.checkBalance(convertToLegacyAddress(coinData.getWallet())));
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.listUnspent(convertToLegacyAddress(coinData.getWallet())));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.checkBalance(convertToLegacyAddress(coinData.getWallet())));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.listUnspent(convertToLegacyAddress(coinData.getWallet())));
|
||||
}
|
||||
|
||||
private Integer calculateEstimatedTransactionSize(String outputAddress, String outAmount) {
|
||||
try {
|
||||
SignTask.PaymentToSign ps=constructPayment(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendPayment onNeedSendPaymentBackup=onNeedSendPayment;
|
||||
onNeedSendPayment=(tx)->{}; // empty function to bypass exception
|
||||
SignTask.TransactionToSign ps= constructTransaction(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendTransaction onNeedSendTransactionBackup = onNeedSendTransaction;
|
||||
onNeedSendTransaction =(tx)->{}; // empty function to bypass exception
|
||||
|
||||
byte[][] hashesToSign=ps.getHashesToSign();
|
||||
byte[] signFromCard = new byte[64 * hashesToSign.length];
|
||||
byte[] txForSend=ps.onSignCompleted(signFromCard);
|
||||
onNeedSendPayment=onNeedSendPaymentBackup;
|
||||
onNeedSendTransaction = onNeedSendTransactionBackup;
|
||||
Log.e(TAG,"txForSend.length="+String.valueOf(txForSend.length));
|
||||
return txForSend.length;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -686,7 +686,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
final ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener () {
|
||||
final ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
BigDecimal fee;
|
||||
|
|
@ -695,13 +695,13 @@ public class BtcCashEngine extends CoinEngine {
|
|||
fee = new BigDecimal(electrumRequest.getResultString()); //fee per KB
|
||||
|
||||
if (fee.equals(BigDecimal.ZERO)) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
|
||||
// if (calcSize != 0) {
|
||||
fee = fee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024)); // (per KB -> per byte)*size
|
||||
// } else {
|
||||
// serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
// serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
// }
|
||||
|
||||
//compare fee to usual relay fee
|
||||
|
|
@ -732,9 +732,9 @@ public class BtcCashEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -742,7 +742,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
final String txStr = BTCUtils.toHex(txForSend);
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumBodyListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumBodyListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
|
|
@ -773,10 +773,10 @@ public class BtcCashEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumBodyListener);
|
||||
serverApiElectrum.setResponseListener(electrumBodyListener);
|
||||
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse((ctx.getBlockchain() == Blockchain.Bitcoin ? "https://blockchain.info/address/" : "https://testnet.blockchain.info/address/") + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
final ArrayList<UnspentOutputInfo> unspentOutputs;
|
||||
checkBlockchainDataExists();
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ public class BtcEngine extends CoinEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -517,7 +517,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
byte[] txForSend = BTCUtils.buildTXForSend(targetAddress, myAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -527,7 +527,7 @@ public class BtcEngine extends CoinEngine {
|
|||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
Log.i(TAG, "onSuccess: "+electrumRequest.getMethod());
|
||||
|
|
@ -576,7 +576,7 @@ public class BtcEngine extends CoinEngine {
|
|||
String hash = jsUnspent.getString("tx_hash");
|
||||
if (height != -1) {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getTransaction(walletAddress, hash));
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -617,14 +617,14 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.checkBalance(coinData.getWallet()));
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.listUnspent(coinData.getWallet()));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.checkBalance(coinData.getWallet()));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.listUnspent(coinData.getWallet()));
|
||||
}
|
||||
|
||||
protected Integer calculateEstimatedTransactionSize(String outputAddress, String outAmount) {
|
||||
//todo - правильней было бы использовать constructPayment
|
||||
//todo - правильней было бы использовать constructTransaction
|
||||
try {
|
||||
// String myAddress = coinData.getWallet();
|
||||
// byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -685,14 +685,14 @@ public class BtcEngine extends CoinEngine {
|
|||
//
|
||||
// byte[] realTX = BTCUtils.buildTXForSend(outputAddress, myAddress, unspentOutputs, amount, change);
|
||||
|
||||
SignTask.PaymentToSign ps=constructPayment(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendPayment onNeedSendPaymentBackup=onNeedSendPayment;
|
||||
onNeedSendPayment=(tx)->{}; // empty function to bypass exception
|
||||
SignTask.TransactionToSign ps= constructTransaction(new Amount(outAmount, getBalanceCurrency()),new Amount("0.00",getFeeCurrency()), true, outputAddress );
|
||||
OnNeedSendTransaction onNeedSendTransactionBackup = onNeedSendTransaction;
|
||||
onNeedSendTransaction =(tx)->{}; // empty function to bypass exception
|
||||
|
||||
byte[][] hashesToSign=ps.getHashesToSign();
|
||||
byte[] signFromCard = new byte[64 * hashesToSign.length];
|
||||
byte[] txForSend=ps.onSignCompleted(signFromCard);
|
||||
onNeedSendPayment=onNeedSendPaymentBackup;
|
||||
onNeedSendTransaction = onNeedSendTransactionBackup;
|
||||
Log.e(TAG,"txForSend.length="+String.valueOf(txForSend.length));
|
||||
return txForSend.length;
|
||||
|
||||
|
|
@ -717,14 +717,14 @@ public class BtcEngine extends CoinEngine {
|
|||
|
||||
final ServerApiCommon serverApiCommon = new ServerApiCommon();
|
||||
|
||||
final ServerApiCommon.EstimateFeeListener estimateFeeListener = new ServerApiCommon.EstimateFeeListener() {
|
||||
final ServerApiCommon.EstimatedFeeListener estimatedFeeListener = new ServerApiCommon.EstimatedFeeListener() {
|
||||
@Override
|
||||
public void onSuccess(int blockCount, String estimateFeeResponse) {
|
||||
BigDecimal fee = new BigDecimal(estimateFeeResponse); // BTC per 1 kb
|
||||
|
||||
if (fee.equals(BigDecimal.ZERO)) {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiCommon.estimateFee(blockCount);
|
||||
serverApiCommon.requestBtcEstimatedFee(blockCount);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -733,7 +733,7 @@ public class BtcEngine extends CoinEngine {
|
|||
fee = fee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024), BigDecimal.ROUND_DOWN); // per Kb -> per byte
|
||||
} else {
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiCommon.estimateFee(blockCount);
|
||||
serverApiCommon.requestBtcEstimatedFee(blockCount);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -763,18 +763,18 @@ public class BtcEngine extends CoinEngine {
|
|||
public void onFail(int blockCount, String message) {
|
||||
// TODO - add fail counter to terminate after NNN tries
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiCommon.estimateFee(blockCount);
|
||||
serverApiCommon.requestBtcEstimatedFee(blockCount);
|
||||
return;
|
||||
}
|
||||
ctx.setError(ctx.getContext().getString(R.string.cannot_calculate_fee_wrong_data_received_from_node));
|
||||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiCommon.setEstimateFee(estimateFeeListener);
|
||||
serverApiCommon.setBtcEstimatedFeeListener(estimatedFeeListener);
|
||||
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_PRIORITY);
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_NORMAL);
|
||||
serverApiCommon.estimateFee(ServerApiCommon.ESTIMATE_FEE_MINIMAL);
|
||||
serverApiCommon.requestBtcEstimatedFee(ServerApiCommon.ESTIMATE_FEE_PRIORITY);
|
||||
serverApiCommon.requestBtcEstimatedFee(ServerApiCommon.ESTIMATE_FEE_NORMAL);
|
||||
serverApiCommon.requestBtcEstimatedFee(ServerApiCommon.ESTIMATE_FEE_MINIMAL);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -783,7 +783,7 @@ public class BtcEngine extends CoinEngine {
|
|||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
final String txStr = BTCUtils.toHex(txForSend);
|
||||
|
||||
ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener() {
|
||||
ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
|
|
@ -814,10 +814,10 @@ public class BtcEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.broadcast(ctx.getCoinData().getWallet(), txStr));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import android.net.Uri;
|
|||
import android.text.InputFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.data.network.ElectrumRequest;
|
||||
import com.tangem.data.network.InsightApi;
|
||||
import com.tangem.data.network.ServerApiInsight;
|
||||
import com.tangem.data.network.model.InsightResponse;
|
||||
import com.tangem.domain.wallet.BTCUtils;
|
||||
|
|
@ -26,10 +24,6 @@ import com.tangem.util.DecimalDigitsInputFilter;
|
|||
import com.tangem.util.DerEncodingUtil;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
|
@ -179,7 +173,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://live.blockcypher.com/ltc/address/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +391,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
final ArrayList<UnspentOutputInfo> unspentOutputs;
|
||||
checkBlockchainDataExists();
|
||||
|
||||
|
|
@ -442,7 +436,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -492,7 +486,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
byte[] txForSend=BTCUtils.buildTXForSend(targetAddress, myAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -502,7 +496,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiInsight serverApiInsight = new ServerApiInsight();
|
||||
|
||||
ServerApiInsight.InsightBodyListener insightBodyListener = new ServerApiInsight.InsightBodyListener() {
|
||||
ServerApiInsight.ResponseListener responseListener = new ServerApiInsight.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InsightResponse insightResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -562,7 +556,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
for (InsightResponse utxo : utxoList) {
|
||||
//if (height != -1) { TODO: check
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_TRANSACTION, "", utxo.getTxid());
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_TRANSACTION, "", utxo.getTxid());
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -582,10 +576,10 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiInsight.setInsightResponse(insightBodyListener);
|
||||
serverApiInsight.setResponseListener(responseListener);
|
||||
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_ADDRESS, coinData.getWallet(), "");
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_UNSPENT_OUTPUTS, coinData.getWallet(), "");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_ADDRESS, coinData.getWallet(), "");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_UNSPENT_OUTPUTS, coinData.getWallet(), "");
|
||||
}
|
||||
|
||||
// private final static BigDecimal relayFee = new BigDecimal(0.00001);
|
||||
|
|
@ -600,7 +594,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
|
||||
final ServerApiInsight serverApiInsight = new ServerApiInsight();
|
||||
|
||||
final ServerApiInsight.InsightBodyListener insightBodyListener = new ServerApiInsight.InsightBodyListener () {
|
||||
final ServerApiInsight.ResponseListener responseListener = new ServerApiInsight.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InsightResponse insightResponse) {
|
||||
if ( method.equals(ServerApiInsight.INSIGHT_FEE)) {
|
||||
|
|
@ -610,7 +604,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
BigDecimal maxFee = new BigDecimal(insightResponse.getFee6());
|
||||
|
||||
if (minFee.equals(BigDecimal.ZERO) || normalFee.equals(BigDecimal.ZERO) || maxFee.equals(BigDecimal.ZERO)) {
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_FEE, "","");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_FEE, "","");
|
||||
}
|
||||
|
||||
minFee = minFee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024)); // (per KB -> per byte)*size
|
||||
|
|
@ -650,9 +644,9 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInsight.setInsightResponse(insightBodyListener);
|
||||
serverApiInsight.setResponseListener(responseListener);
|
||||
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_FEE, "", "");
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_FEE, "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -660,7 +654,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
final ServerApiInsight serverApiInsight = new ServerApiInsight();
|
||||
final String txStr = BTCUtils.toHex(txForSend);
|
||||
|
||||
final ServerApiInsight.InsightBodyListener insightBodyListener = new ServerApiInsight.InsightBodyListener () {
|
||||
final ServerApiInsight.ResponseListener responseListener = new ServerApiInsight.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InsightResponse insightResponse) {
|
||||
if (method.equals(ServerApiInsight.INSIGHT_SEND)) {
|
||||
|
|
@ -700,8 +694,8 @@ public class DucatusEngine extends BtcEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInsight.setInsightResponse(insightBodyListener);
|
||||
serverApiInsight.setResponseListener(responseListener);
|
||||
|
||||
serverApiInsight.insight(ServerApiInsight.INSIGHT_SEND, "", txStr);
|
||||
serverApiInsight.requestData(ServerApiInsight.INSIGHT_SEND, "", txStr);
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
if (ctx.getBlockchain() == Blockchain.EthereumTestNet)
|
||||
return Uri.parse("https://rinkeby.etherscan.io/address/" + ctx.getCoinData().getWallet());
|
||||
else
|
||||
|
|
@ -379,9 +379,9 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
|
||||
|
||||
Log.e(TAG, "Construct payment " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
Log.e(TAG, "Construct transaction " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -404,7 +404,7 @@ public class EthEngine extends CoinEngine {
|
|||
|
||||
final EthTransaction tx = EthTransaction.create(to, weiAmount, nonceValue, gasPrice, gasLimit, this.getChainId());
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -455,7 +455,7 @@ public class EthEngine extends CoinEngine {
|
|||
Log.e(TAG, "ETH_v: " +String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -464,8 +464,8 @@ public class EthEngine extends CoinEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -517,18 +517,18 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
String gasPrice = infuraResponse.getResult();
|
||||
|
|
@ -566,9 +566,9 @@ public class EthEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -577,8 +577,8 @@ public class EthEngine extends CoinEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
if (method.equals(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -604,9 +604,9 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class LtcEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://live.blockcypher.com/ltc/address/" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ public class LtcEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
final ArrayList<UnspentOutputInfo> unspentOutputs;
|
||||
checkBlockchainDataExists();
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ public class LtcEngine extends BtcEngine {
|
|||
bodyDoubleHash[i] = Util.calculateSHA256(bodyHash[i]);
|
||||
}
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
|
|
@ -489,7 +489,7 @@ public class LtcEngine extends BtcEngine {
|
|||
}
|
||||
|
||||
byte[] txForSend=BTCUtils.buildTXForSend(targetAddress, myAddress, unspentOutputs, amountFinal, changeFinal);
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -507,7 +507,7 @@ public class LtcEngine extends BtcEngine {
|
|||
|
||||
final ServerApiElectrum serverApiElectrum = new ServerApiElectrum();
|
||||
|
||||
final ServerApiElectrum.ElectrumRequestDataListener electrumListener = new ServerApiElectrum.ElectrumRequestDataListener () {
|
||||
final ServerApiElectrum.ResponseListener electrumListener = new ServerApiElectrum.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(ElectrumRequest electrumRequest) {
|
||||
BigDecimal fee;
|
||||
|
|
@ -516,13 +516,13 @@ public class LtcEngine extends BtcEngine {
|
|||
fee = new BigDecimal(electrumRequest.getResultString()); //fee per KB
|
||||
|
||||
if (fee.equals(BigDecimal.ZERO)) {
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
|
||||
// if (calcSize != 0) {
|
||||
fee = fee.multiply(new BigDecimal(calcSize)).divide(new BigDecimal(1024)); // (per KB -> per byte)*size
|
||||
// } else {
|
||||
// serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
// serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
// }
|
||||
|
||||
//compare fee to usual relay fee
|
||||
|
|
@ -553,8 +553,8 @@ public class LtcEngine extends BtcEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiElectrum.setElectrumRequestData(electrumListener);
|
||||
serverApiElectrum.setResponseListener(electrumListener);
|
||||
|
||||
serverApiElectrum.electrumRequestData(ctx, ElectrumRequest.getFee());
|
||||
serverApiElectrum.requestData(ctx, ElectrumRequest.getFee());
|
||||
}
|
||||
}
|
||||
|
|
@ -66,12 +66,12 @@ public class RskEngine extends EthEngine {
|
|||
public Uri getShareWalletUri() { return Uri.parse(ctx.getCoinData().getWallet()); }
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() { return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet()); }
|
||||
public Uri getWalletExplorerUri() { return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet()); }
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) {
|
||||
|
||||
Log.e(TAG, "Construct payment " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
Log.e(TAG, "Construct transaction " + amountValue.toString() + " with fee " + feeValue.toString() + (IncFee ? " including" : " excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -95,7 +95,7 @@ public class RskEngine extends EthEngine {
|
|||
|
||||
final EthTransaction tx = EthTransaction.create(to, weiAmount, nonceValue, gasPrice, gasLimit, chainId);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -146,7 +146,7 @@ public class RskEngine extends EthEngine {
|
|||
Log.e(TAG, "RSK_v: " +String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
|
|
@ -155,8 +155,8 @@ public class RskEngine extends EthEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -208,18 +208,18 @@ public class RskEngine extends EthEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock gasPrice listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData gasPrice listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
String gasPrice = rootstockResponse.getResult();
|
||||
|
|
@ -257,9 +257,9 @@ public class RskEngine extends EthEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -268,7 +268,7 @@ public class RskEngine extends EthEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
if (method.equals(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -294,9 +294,9 @@ public class RskEngine extends EthEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() { return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet()); } // Only RSK explorer for now
|
||||
public Uri getWalletExplorerUri() { return Uri.parse("https://explorer.rsk.co/address/" + ctx.getCoinData().getWallet()); } // Only RSK explorer for now
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUri() { return Uri.parse(ctx.getCoinData().getWallet()); }
|
||||
|
|
@ -186,16 +186,16 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
if (amountValue.getCurrency().equals(Blockchain.Rootstock.getCurrency())) {
|
||||
return constructPaymentRBTC(feeValue, amountValue, IncFee, targetAddress);
|
||||
return constructTransactionRBTC(feeValue, amountValue, IncFee, targetAddress);
|
||||
} else {
|
||||
return constructPaymentToken(feeValue, amountValue, IncFee, targetAddress);
|
||||
return constructTransactionToken(feeValue, amountValue, IncFee, targetAddress);
|
||||
}
|
||||
}
|
||||
|
||||
private SignTask.PaymentToSign constructPaymentRBTC(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct RBTC payment "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
private SignTask.TransactionToSign constructTransactionRBTC(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct RBTC transaction "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -219,7 +219,7 @@ public class RskTokenEngine extends TokenEngine {
|
|||
|
||||
final EthTransaction tx = EthTransaction.create(to, weiAmount, nonceValue, gasPrice, gasLimit, chainId);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -270,14 +270,14 @@ public class RskTokenEngine extends TokenEngine {
|
|||
Log.e(TAG,"RSK_v "+ String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private SignTask.PaymentToSign constructPaymentToken(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct TOKEN payment "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
private SignTask.TransactionToSign constructTransactionToken(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct TOKEN transaction "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -327,7 +327,7 @@ public class RskTokenEngine extends TokenEngine {
|
|||
byte[] data = BTCUtils.fromHex(cmd);
|
||||
EthTransaction tx = EthTransaction.create(contractAddress, amountZero, nonceValue, gasPrice, gasLimit, chainId, data);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -378,7 +378,7 @@ public class RskTokenEngine extends TokenEngine {
|
|||
Log.e(TAG,"RSK_v: "+ String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
|
||||
}
|
||||
|
|
@ -389,8 +389,8 @@ public class RskTokenEngine extends TokenEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -436,9 +436,9 @@ public class RskTokenEngine extends TokenEngine {
|
|||
// Log.i("$TAG eth_call", balanceCap)
|
||||
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -465,16 +465,16 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock gasPrice listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData gasPrice listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse rootstockResponse) {
|
||||
String gasPrice = rootstockResponse.getResult();
|
||||
|
|
@ -516,9 +516,9 @@ public class RskTokenEngine extends TokenEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -527,8 +527,8 @@ public class RskTokenEngine extends TokenEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiRootstock serverApiRootstock = new ServerApiRootstock();
|
||||
// request rootstock listener
|
||||
ServerApiRootstock.RootstockBodyListener rootstockBodyListener = new ServerApiRootstock.RootstockBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiRootstock.ResponseListener responseListener = new ServerApiRootstock.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
if (method.equals(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -554,9 +554,9 @@ public class RskTokenEngine extends TokenEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiRootstock.setRootstockResponse(rootstockBodyListener);
|
||||
serverApiRootstock.setResponseListener(responseListener);
|
||||
|
||||
serverApiRootstock.rootstock(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiRootstock.requestData(ServerApiRootstock.ROOTSTOCK_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ public class TokenEngine extends CoinEngine {
|
|||
|
||||
|
||||
@Override
|
||||
public Uri getShareWalletUriExplorer() {
|
||||
public Uri getWalletExplorerUri() {
|
||||
return Uri.parse("https://etherscan.io/token/" + getContractAddress(ctx.getCard()) + "?a=" + ctx.getCoinData().getWallet());
|
||||
}
|
||||
|
||||
|
|
@ -431,16 +431,16 @@ public class TokenEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SignTask.PaymentToSign constructPayment(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
public SignTask.TransactionToSign constructTransaction(Amount amountValue, Amount feeValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
if (amountValue.getCurrency().equals(Blockchain.Ethereum.getCurrency())) {
|
||||
return constructPaymentETH(feeValue, amountValue, IncFee, targetAddress);
|
||||
return constructTransactionETH(feeValue, amountValue, IncFee, targetAddress);
|
||||
} else {
|
||||
return constructPaymentToken(feeValue, amountValue, IncFee, targetAddress);
|
||||
return constructTransactionToken(feeValue, amountValue, IncFee, targetAddress);
|
||||
}
|
||||
}
|
||||
|
||||
private SignTask.PaymentToSign constructPaymentETH(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct ETH payment "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
private SignTask.TransactionToSign constructTransactionETH(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct ETH transaction "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -465,7 +465,7 @@ public class TokenEngine extends CoinEngine {
|
|||
|
||||
final EthTransaction tx = EthTransaction.create(to, weiAmount, nonceValue, gasPrice, gasLimit, chainId);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -516,14 +516,14 @@ public class TokenEngine extends CoinEngine {
|
|||
Log.e(TAG,"ETH_v "+ String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private SignTask.PaymentToSign constructPaymentToken(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct TOKEN payment "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
private SignTask.TransactionToSign constructTransactionToken(Amount feeValue, Amount amountValue, boolean IncFee, String targetAddress) throws Exception {
|
||||
Log.e(TAG, "Construct TOKEN transaction "+amountValue.toString()+" with fee "+feeValue.toString()+(IncFee?" including":" excluding"));
|
||||
|
||||
BigInteger nonceValue = coinData.getConfirmedTXCount();
|
||||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
|
@ -573,7 +573,7 @@ public class TokenEngine extends CoinEngine {
|
|||
byte[] data = BTCUtils.fromHex(cmd);
|
||||
EthTransaction tx = EthTransaction.create(contractAddress, amountZero, nonceValue, gasPrice, gasLimit, chainId, data);
|
||||
|
||||
return new SignTask.PaymentToSign() {
|
||||
return new SignTask.TransactionToSign() {
|
||||
@Override
|
||||
public boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod) {
|
||||
return signingMethod == TangemCard.SigningMethod.Sign_Hash;
|
||||
|
|
@ -624,7 +624,7 @@ public class TokenEngine extends CoinEngine {
|
|||
Log.e(TAG,"ETH_v: "+ String.valueOf(v));
|
||||
|
||||
byte[] txForSend = tx.getEncoded();
|
||||
notifyOnNeedSendPayment(txForSend);
|
||||
notifyOnNeedSendTransaction(txForSend);
|
||||
return txForSend;
|
||||
|
||||
}
|
||||
|
|
@ -635,8 +635,8 @@ public class TokenEngine extends CoinEngine {
|
|||
@Override
|
||||
public void requestBalanceAndUnspentTransactions(BlockchainRequestsCallbacks blockchainRequestsCallbacks) {
|
||||
final ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
switch (method) {
|
||||
|
|
@ -682,9 +682,9 @@ public class TokenEngine extends CoinEngine {
|
|||
// Log.i("$TAG eth_call", balanceCap)
|
||||
|
||||
if (blockchainRequestsCallbacks.allowAdvance()) {
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_BALANCE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_TRANSACTION_COUNT, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GET_PENDING_COUNT, 67, coinData.getWallet(), "", "");
|
||||
} else {
|
||||
ctx.setError("Terminated by user");
|
||||
}
|
||||
|
|
@ -711,16 +711,16 @@ public class TokenEngine extends CoinEngine {
|
|||
}
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_CALL, 67, coinData.getWallet(), getContractAddress(ctx.getCard()), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFee(BlockchainRequestsCallbacks blockchainRequestsCallbacks, String targetAddress, Amount amount) {
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
String gasPrice = infuraResponse.getResult();
|
||||
|
|
@ -762,9 +762,9 @@ public class TokenEngine extends CoinEngine {
|
|||
blockchainRequestsCallbacks.onComplete(false);
|
||||
}
|
||||
};
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_GAS_PRICE, 67, coinData.getWallet(), "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -773,8 +773,8 @@ public class TokenEngine extends CoinEngine {
|
|||
String txStr = String.format("0x%s", BTCUtils.toHex(txForSend));
|
||||
|
||||
ServerApiInfura serverApiInfura = new ServerApiInfura();
|
||||
// request infura eth gasPrice listener
|
||||
ServerApiInfura.InfuraBodyListener infuraBodyListener = new ServerApiInfura.InfuraBodyListener() {
|
||||
// request requestData eth gasPrice listener
|
||||
ServerApiInfura.ResponseListener responseListener = new ServerApiInfura.ResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String method, InfuraResponse infuraResponse) {
|
||||
if (method.equals(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION)) {
|
||||
|
|
@ -800,9 +800,9 @@ public class TokenEngine extends CoinEngine {
|
|||
}
|
||||
};
|
||||
|
||||
serverApiInfura.setInfuraResponse(infuraBodyListener);
|
||||
serverApiInfura.setResponseListener(responseListener);
|
||||
|
||||
serverApiInfura.infura(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
serverApiInfura.requestData(ServerApiInfura.INFURA_ETH_SEND_RAW_TRANSACTION, 67, coinData.getWallet(), "", txStr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ import com.tangem.tangemcard.data.TangemCard
|
|||
import com.tangem.tangemcard.data.loadFromBundle
|
||||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_confirm_payment.*
|
||||
import kotlinx.android.synthetic.main.activity_confirm_transaction.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
class ConfirmTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
|
@ -41,7 +41,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_confirm_payment)
|
||||
setContentView(R.layout.activity_confirm_transaction)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
@ -74,7 +74,9 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
btnSend.visibility = View.INVISIBLE
|
||||
|
||||
rgFee.isEnabled = !(ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet || ctx.blockchain == Blockchain.Token || ctx.blockchain == Blockchain.BitcoinCash || ctx.blockchain == Blockchain.Litecoin)
|
||||
for (lol in rgFee.touchables) {
|
||||
lol.isEnabled = !(ctx.blockchain == Blockchain.Ethereum || ctx.blockchain == Blockchain.EthereumTestNet || ctx.blockchain == Blockchain.Token || ctx.blockchain == Blockchain.BitcoinCash || ctx.blockchain == Blockchain.Litecoin)
|
||||
}
|
||||
|
||||
// set listeners
|
||||
rgFee.setOnCheckedChangeListener { _, checkedId -> doSetFee(checkedId) }
|
||||
|
|
@ -175,7 +177,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
|
||||
override fun allowAdvance(): Boolean {
|
||||
return UtilHelper.isOnline(this@ConfirmPaymentActivity)
|
||||
return UtilHelper.isOnline(this@ConfirmTransactionActivity)
|
||||
}
|
||||
},
|
||||
etWallet.text.toString(),
|
||||
|
|
@ -199,7 +201,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == Constant.REQUEST_CODE_SIGN_PAYMENT) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SIGN_TRANSACTION) {
|
||||
if (data != null && data.extras != null) {
|
||||
if (data.extras!!.containsKey("UID") && data.extras!!.containsKey("Card")) {
|
||||
val updatedCard = TangemCard(data.getStringExtra("UID"))
|
||||
|
|
@ -222,7 +224,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
finish()
|
||||
} else if (requestCode == Constant.REQUEST_CODE_REQUEST_PIN2_) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
val intent = Intent(baseContext, SignPaymentActivity::class.java)
|
||||
val intent = Intent(baseContext, SignTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_TARGET_ADDRESS, etWallet!!.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT, etAmount.text.toString())
|
||||
|
|
@ -230,9 +232,9 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
intent.putExtra(Constant.EXTRA_FEE, etFee.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_FEE_CURRENCY, tvCurrency2.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_FEE_INCLUDED, isIncludeFee)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SIGN_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SIGN_TRANSACTION)
|
||||
} else
|
||||
Toast.makeText(baseContext, R.string.pin_2_is_required_to_sign_the_payment, Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(baseContext, R.string.pin_2_is_required_to_sign_the_transaction, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,16 +20,16 @@ import com.tangem.domain.wallet.CoinEngineFactory
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_prepare_payment.*
|
||||
import kotlinx.android.synthetic.main.activity_prepare_transaction.*
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
class PrepareTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PreparePaymentActivity::class.java.simpleName
|
||||
val TAG: String = PrepareTransactionActivity::class.java.simpleName
|
||||
fun callingIntent(context: Context, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, PreparePaymentActivity::class.java)
|
||||
val intent = Intent(context, PrepareTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
return intent
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_payment)
|
||||
setContentView(R.layout.activity_prepare_transaction)
|
||||
|
||||
App.getNavigatorComponent().inject(this)
|
||||
|
||||
|
|
@ -118,13 +118,13 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val intent = Intent(baseContext, ConfirmPaymentActivity::class.java)
|
||||
val intent = Intent(baseContext, ConfirmTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_TARGET_ADDRESS, etWallet!!.text.toString())
|
||||
intent.putExtra(Constant.EXTRA_FEE_INCLUDED, (rgIncFee!!.checkedRadioButtonId == R.id.rbFeeIn))
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT, strAmount)
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT_CURRENCY, tvCurrency.text.toString())
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_PAYMENT__)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_TRANSACTION__)
|
||||
}
|
||||
|
||||
ivCamera.setOnClickListener { navigator.showQrScanActivity(this, Constant.REQUEST_CODE_SCAN_QR) }
|
||||
|
|
@ -169,7 +169,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
etWallet!!.setText(code)
|
||||
} else if (requestCode == Constant.REQUEST_CODE_SEND_PAYMENT__) {
|
||||
} else if (requestCode == Constant.REQUEST_CODE_SEND_TRANSACTION__) {
|
||||
setResult(resultCode, data)
|
||||
finish()
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
if (success)
|
||||
finishWithSuccess()
|
||||
else
|
||||
finishWithError(this@SendTransactionActivity.getString(R.string.try_again_failed_to_send_transaction))
|
||||
finishWithError(ctx.error)
|
||||
}
|
||||
|
||||
override fun onProgress() {
|
||||
|
|
|
|||
|
|
@ -28,18 +28,18 @@ import com.tangem.tangemcard.tasks.SignTask
|
|||
import com.tangem.tangemcard.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_sign_payment.*
|
||||
import kotlinx.android.synthetic.main.activity_sign_transaction.*
|
||||
|
||||
class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
val TAG: String = SignPaymentActivity::class.java.simpleName
|
||||
val TAG: String = SignTransactionActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var signPaymentTask: SignTask? = null
|
||||
private var signTransactionTask: SignTask? = null
|
||||
|
||||
private lateinit var amount: CoinEngine.Amount
|
||||
private lateinit var fee: CoinEngine.Amount
|
||||
|
|
@ -51,7 +51,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_sign_payment)
|
||||
setContentView(R.layout.activity_sign_transaction)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
@ -76,21 +76,21 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
public override fun onPause() {
|
||||
nfcManager.onPause()
|
||||
if (signPaymentTask != null)
|
||||
signPaymentTask!!.cancel(true)
|
||||
if (signTransactionTask != null)
|
||||
signTransactionTask!!.cancel(true)
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
// dismiss enable NFC dialog
|
||||
nfcManager.onStop()
|
||||
if (signPaymentTask != null)
|
||||
signPaymentTask!!.cancel(true)
|
||||
if (signTransactionTask != null)
|
||||
signTransactionTask!!.cancel(true)
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SEND_PAYMENT_) {
|
||||
if (requestCode == Constant.REQUEST_CODE_SEND_TRANSACTION_) {
|
||||
setResult(resultCode, data)
|
||||
finish()
|
||||
return
|
||||
|
|
@ -127,18 +127,18 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
|
||||
val coinEngine = CoinEngineFactory.create(ctx)
|
||||
?: throw CardProtocol.TangemException("Can't create CoinEngine!")
|
||||
coinEngine.setOnNeedSendPayment { tx ->
|
||||
coinEngine.setOnNeedSendTransaction { tx ->
|
||||
if (tx != null) {
|
||||
val intent = Intent(this, SendTransactionActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra(Constant.EXTRA_TX, tx)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_PAYMENT_)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_TRANSACTION_)
|
||||
}
|
||||
}
|
||||
val paymentToSign = coinEngine.constructPayment(amount, fee, isIncludeFee, outAddressStr)
|
||||
val transactionToSign = coinEngine.constructTransaction(amount, fee, isIncludeFee, outAddressStr)
|
||||
|
||||
signPaymentTask = SignTask(ctx.card, NfcReader(nfcManager, isoDep), App.localStorage, App.pinStorage, this, paymentToSign)
|
||||
signPaymentTask!!.start()
|
||||
signTransactionTask = SignTask(ctx.card, NfcReader(nfcManager, isoDep), App.localStorage, App.pinStorage, this, transactionToSign)
|
||||
signTransactionTask!!.start()
|
||||
} else
|
||||
nfcManager.ignoreTag(isoDep.tag)
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
|
||||
override fun onReadFinish(cardProtocol: CardProtocol?) {
|
||||
signPaymentTask = null
|
||||
signTransactionTask = null
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.error == null) {
|
||||
progressBar!!.post {
|
||||
|
|
@ -240,7 +240,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
|
||||
override fun onReadCancel() {
|
||||
signPaymentTask = null
|
||||
signTransactionTask = null
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
try {
|
||||
|
|
@ -6,11 +6,9 @@ import android.app.Dialog
|
|||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatDialogFragment
|
||||
import android.widget.ProgressBar
|
||||
import com.tangem.presentation.activity.SignPaymentActivity
|
||||
import com.tangem.presentation.event.ReadAfterRequest
|
||||
import com.tangem.presentation.event.ReadBeforeRequest
|
||||
import com.tangem.presentation.event.ReadWait
|
||||
import com.tangem.presentation.event.TransactionFinishWithSuccess
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
btnExplore.setOnClickListener {
|
||||
val engine = CoinEngineFactory.create(ctx)
|
||||
startActivity(Intent(Intent.ACTION_VIEW, engine?.shareWalletUriExplorer))
|
||||
startActivity(Intent(Intent.ACTION_VIEW, engine?.walletExplorerUri))
|
||||
}
|
||||
btnCopy.setOnClickListener { doShareWallet(false) }
|
||||
|
||||
|
|
@ -157,13 +157,13 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
getString(R.string.via_cryptonit) -> {
|
||||
val intent = Intent(activity, PrepareCryptonitWithdrawalActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_TRANSACTION)
|
||||
}
|
||||
|
||||
getString(R.string.via_kraken) -> {
|
||||
val intent = Intent(activity, PrepareKrakenWithdrawalActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_TRANSACTION)
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
else if (ctx.card!!.remainingSignatures == 0)
|
||||
UtilHelper.showSingleToast(context, getString(R.string.card_has_no_remaining_signature))
|
||||
else
|
||||
(activity as LoadedWalletActivity).navigator.showPreparePayment(context as Activity, ctx)
|
||||
(activity as LoadedWalletActivity).navigator.showPrepareTransaction(context as Activity, ctx)
|
||||
else
|
||||
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
@ -259,8 +259,8 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiTangem.setArtworkListener(artworkListener)
|
||||
|
||||
// request rate info listener
|
||||
serverApiCommon.setRateInfoData {
|
||||
if (activity == null || !UtilHelper.isOnline(activity!!)) return@setRateInfoData
|
||||
serverApiCommon.setRateInfoListener {
|
||||
if (activity == null || !UtilHelper.isOnline(activity!!)) return@setRateInfoListener
|
||||
val rate = it.priceUsd.toFloat()
|
||||
ctx.coinData!!.rate = rate
|
||||
ctx.coinData!!.rateAlter = rate
|
||||
|
|
@ -417,7 +417,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
updateViews()
|
||||
}
|
||||
|
||||
Constant.REQUEST_CODE_SEND_PAYMENT, Constant.REQUEST_CODE_RECEIVE_PAYMENT -> {
|
||||
Constant.REQUEST_CODE_SEND_TRANSACTION, Constant.REQUEST_CODE_RECEIVE_TRANSACTION -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
ctx.coinData?.clearInfo()
|
||||
srl?.postDelayed({ this.refresh() }, 5000)
|
||||
|
|
@ -712,7 +712,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
throw Exception("Can''t get rate for blockchain " + ctx.blockchainName)
|
||||
}
|
||||
}
|
||||
serverApiCommon.rateInfoData(cryptoId)
|
||||
serverApiCommon.requestRateInfo(cryptoId)
|
||||
} else {
|
||||
ctx.error = getString(R.string.no_connection)
|
||||
updateViews()
|
||||
|
|
|
|||
|
|
@ -1,338 +1,338 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:ignore="Autofill"
|
||||
tools:context="com.tangem.presentation.activity.ConfirmPaymentActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:text="@string/send_payment"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llPayment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/btn_light"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/from_banknote"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCardID"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="BB00 0000 1210 0233" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/with_balance"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBalance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="4.51735 BTC" />
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/send_to_wallet"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etWallet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/target_wallet_address"
|
||||
android:inputType="text"
|
||||
android:maxLines="2"
|
||||
android:padding="12dp"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/amount"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvIncFee"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView3"
|
||||
app:layout_constraintLeft_toRightOf="@+id/textView3"
|
||||
tools:text="(including fee)" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etAmount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/payment_amount"
|
||||
android:inputType="numberDecimal"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/black"
|
||||
android:textColorLink="@color/colorPrimary"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/m_btc"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/etAmount"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llFee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintTop_toBottomOf="@+id/llPayment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/fee"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<info.hoang8f.android.segmented.SegmentedGroup
|
||||
android:id="@+id/rgFee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:checkedButton="@+id/rbNormalFee"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:sc_border_width="2dp"
|
||||
app:sc_corner_radius="10dp"
|
||||
app:sc_tint_color="@color/colorPrimary">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMinimalFee"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/minimal"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbNormalFee"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/normal"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMaximumFee"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/priority"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
</info.hoang8f.android.segmented.SegmentedGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etFee"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/maax"
|
||||
android:inputType="numberDecimal"
|
||||
android:textColor="@color/black"
|
||||
android:textColorLink="@android:color/holo_blue_dark"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_min="150dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrency2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/m_btc"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/etFee"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFeeEquivalent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tvCurrency2"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSend"
|
||||
style="@style/AppTheme.RoundedCornerMaterialButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/send_1"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="@android:style/Widget.Holo.Light.ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:elevation="1dp"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/colorPrimary"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/llFee" />
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:ignore="Autofill"
|
||||
tools:context="com.tangem.presentation.activity.ConfirmTransactionActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:text="@string/send_transaction"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llTransaction"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/btn_light"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/from_banknote"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCardID"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="BB00 0000 1210 0233" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/with_balance"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBalance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="4.51735 BTC" />
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/send_to_wallet"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etWallet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/target_wallet_address"
|
||||
android:inputType="text"
|
||||
android:maxLines="2"
|
||||
android:padding="12dp"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/amount"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvIncFee"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView3"
|
||||
app:layout_constraintLeft_toRightOf="@+id/textView3"
|
||||
tools:text="(including fee)" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etAmount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/transaction_amount"
|
||||
android:inputType="numberDecimal"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/black"
|
||||
android:textColorLink="@color/colorPrimary"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/m_btc"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/etAmount"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llFee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintTop_toBottomOf="@+id/llTransaction">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/fee"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<info.hoang8f.android.segmented.SegmentedGroup
|
||||
android:id="@+id/rgFee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:checkedButton="@+id/rbNormalFee"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:sc_border_width="2dp"
|
||||
app:sc_corner_radius="10dp"
|
||||
app:sc_tint_color="@color/colorPrimary">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMinimalFee"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/minimal"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbNormalFee"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/normal"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMaximumFee"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/priority"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
</info.hoang8f.android.segmented.SegmentedGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etFee"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/maax"
|
||||
android:inputType="numberDecimal"
|
||||
android:textColor="@color/black"
|
||||
android:textColorLink="@android:color/holo_blue_dark"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_min="150dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrency2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/m_btc"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/etFee"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFeeEquivalent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="@dimen/text_size_1_small"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tvCurrency2"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSend"
|
||||
style="@style/AppTheme.RoundedCornerMaterialButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/send_1"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="@android:style/Widget.Holo.Light.ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:elevation="1dp"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/colorPrimary"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/llFee" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
@ -1,262 +1,262 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.tangem.presentation.activity.PreparePaymentActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:text="@string/send_payment"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llFrom"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/btn_light"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="24dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="24dp"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/from_banknote"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCardID"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="BB00 0000 1210 0233"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/with_balance"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBalance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="4.51735 Btc"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llTo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/card_state_loaded_with_zero"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="32dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/llFrom">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/send_to_wallet"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivCamera"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:src="@drawable/qr_scan"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etWallet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_wallet_address"
|
||||
android:inputType="text|textMultiLine|textNoSuggestions"
|
||||
android:imeOptions="actionNext"
|
||||
android:padding="12dp"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textColorLink="@android:color/holo_blue_dark"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/ivCamera"
|
||||
tools:layout_editor_absoluteY="2dp"/>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/amount"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etAmount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789.,"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_amount"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="numberDecimal"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_min="150dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/m_btc"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/etAmount" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<info.hoang8f.android.segmented.SegmentedGroup
|
||||
android:id="@+id/rgIncFee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:checkedButton="@+id/rbFeeIn"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:sc_border_width="2dp"
|
||||
app:sc_corner_radius="10dp"
|
||||
app:sc_tint_color="@color/colorPrimary"
|
||||
tools:layout_editor_absoluteX="10dp">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbFeeIn"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/including_fee_"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbFeeOut"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/not_including_fee_"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
</info.hoang8f.android.segmented.SegmentedGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/btnVerify"
|
||||
style="@style/AppTheme.RoundedCornerMaterialButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/verify"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.tangem.presentation.activity.PrepareTransactionActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:text="@string/send_transaction"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llFrom"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/btn_light"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="24dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="24dp"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/from_banknote"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCardID"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="BB00 0000 1210 0233"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/with_balance"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBalance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold"
|
||||
tools:text="4.51735 Btc"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llTo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/card_state_loaded_with_zero"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="32dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/llFrom">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/send_to_wallet"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivCamera"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:src="@drawable/qr_scan"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etWallet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_wallet_address"
|
||||
android:inputType="text|textMultiLine|textNoSuggestions"
|
||||
android:imeOptions="actionNext"
|
||||
android:padding="12dp"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textColorLink="@android:color/holo_blue_dark"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/ivCamera"
|
||||
tools:layout_editor_absoluteY="2dp"/>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/amount"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etAmount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789.,"
|
||||
android:fontFamily="@font/maax"
|
||||
android:hint="@string/enter_amount"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="numberDecimal"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_min="150dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/m_btc"
|
||||
android:textColor="@color/primary"
|
||||
android:textSize="@dimen/text_size_1_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/etAmount" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<info.hoang8f.android.segmented.SegmentedGroup
|
||||
android:id="@+id/rgIncFee"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:checkedButton="@+id/rbFeeIn"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:sc_border_width="2dp"
|
||||
app:sc_corner_radius="10dp"
|
||||
app:sc_tint_color="@color/colorPrimary"
|
||||
tools:layout_editor_absoluteX="10dp">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbFeeIn"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/including_fee_"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbFeeOut"
|
||||
style="@style/RadioButton"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/not_including_fee_"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
</info.hoang8f.android.segmented.SegmentedGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/btnVerify"
|
||||
style="@style/AppTheme.RoundedCornerMaterialButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="@font/saira_condensed_bold"
|
||||
android:text="@string/verify"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
@ -1,46 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.tangem.presentation.activity.SignPaymentActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/now_touch_the_banknote_with_id"
|
||||
android:textAlignment="center"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCardID"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
tools:text="CB02 0000 0002 5000" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/to_sign_the_payment"
|
||||
android:textAlignment="center"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/layout_progress_horizontal" />
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.tangem.presentation.activity.SignTransactionActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/now_touch_the_banknote_with_id"
|
||||
android:textAlignment="center"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCardID"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/maax"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
tools:text="CB02 0000 0002 5000" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/maax"
|
||||
android:text="@string/to_sign_the_transaction"
|
||||
android:textAlignment="center"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/layout_progress_horizontal" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
<string name="last_withdrawal">Last withdrawal</string>
|
||||
<string name="try_to_scan_again">Try to scan again</string>
|
||||
<string name="cannot_erase_wallet_with_non_zero_balance">Cannot erase wallet with non-zero balance</string>
|
||||
<string name="send_payment">Send payment</string>
|
||||
<string name="send_transaction">Send payment</string>
|
||||
<string name="from_banknote">From banknote</string>
|
||||
<string name="on_banknote">on banknote</string>
|
||||
<string name="with_balance">with balance</string>
|
||||
|
|
@ -131,16 +131,16 @@
|
|||
<!-- LogoActivity -->
|
||||
<string name="beta">BETA</string>
|
||||
|
||||
<!-- CreateNewWalletActivity, PurgeActivity, SignPaymentActivity -->
|
||||
<!-- CreateNewWalletActivity, PurgeActivity, SignTransactionActivity -->
|
||||
<string name="now_touch_the_banknote_with_id">Now touch the banknote with ID</string>
|
||||
<string name="to_create_the_wallet">to create the wallet</string>
|
||||
<string name="to_erase_the_wallet">to erase the wallet</string>
|
||||
<string name="to_sign_the_payment">to sign the payment</string>
|
||||
<string name="to_sign_the_transaction">to sign the payment</string>
|
||||
<string name="to_change_pin_codes">to change PIN/PIN2 codes</string>
|
||||
<string name="by_tapping_the_card">By tapping the card, you will permanently remove the blockchain wallet. Ensure there will be no further incoming transactions</string>
|
||||
<string name="cannot_erase_wallet">Cannot erase wallet. Make sure you enter correct PIN2!</string>
|
||||
|
||||
<!-- PreparePaymentActivity -->
|
||||
<!-- PrepareTransactionActivity -->
|
||||
<string name="enter_wallet_address">enter wallet address</string>
|
||||
<string name="enter_amount">enter amount</string>
|
||||
<string name="verify">Verify</string>
|
||||
|
|
@ -164,15 +164,15 @@
|
|||
<string name="cannot_sign_transaction_make_sure_you_enter_correct_pin_2">Cannot sign transaction. Make sure you enter correct PIN2!</string>
|
||||
<string name="cannot_sign_transaction_wrong_amount">Amount and fee exceed total wallet balance!</string>
|
||||
|
||||
<!-- PreparePaymentActivity -->
|
||||
<!-- PrepareTransactionActivity -->
|
||||
<string name="not_enough_funds_on_your_card">Not enough funds</string>
|
||||
<string name="unknown_amount_format">Unknown amount format</string>
|
||||
<string name="incorrect_destination_wallet_address">Incorrect destination wallet address</string>
|
||||
<string name="destination_wallet_address_equal_source_address">Destination wallet address equal source address</string>
|
||||
|
||||
<!-- ConfirmPaymentActivity -->
|
||||
<!-- ConfirmTransactionActivity -->
|
||||
<string name="target_wallet_address">target wallet address</string>
|
||||
<string name="payment_amount">payment amount</string>
|
||||
<string name="transaction_amount">payment amount</string>
|
||||
<string name="fee">Fee</string>
|
||||
<string name="send_1">Send</string>
|
||||
<string name="minimal">Minimal</string>
|
||||
|
|
@ -191,7 +191,7 @@
|
|||
<string name="please_wait_for_confirmation_of_incoming_transaction">Please wait for confirmation of incoming transaction</string>
|
||||
<string name="not_enough_eth_for_fee">Not enough ETH funds for fee</string>
|
||||
<string name="not_enough_rbtc_for_fee">Not enough RBTC funds for fee</string>
|
||||
<string name="pin_2_is_required_to_sign_the_payment">PIN2 is required to sign the payment</string>
|
||||
<string name="pin_2_is_required_to_sign_the_transaction">PIN2 is required to sign the payment</string>
|
||||
<string name="not_enough_funds">Not enough funds</string>
|
||||
<string name="service_unavailable">Service unavailable</string>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ dependencies {
|
|||
|
||||
implementation 'com.madgag.spongycastle:core:1.56.0.0'
|
||||
implementation 'com.madgag.spongycastle:prov:1.56.0.0'
|
||||
|
||||
implementation 'net.i2p.crypto:eddsa:0.3.0'
|
||||
}
|
||||
|
||||
sourceCompatibility = "7"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@ import com.tangem.tangemcard.util.Log;
|
|||
import com.tangem.tangemcard.util.PBKDF2;
|
||||
import com.tangem.tangemcard.util.Util;
|
||||
|
||||
import net.i2p.crypto.eddsa.EdDSAEngine;
|
||||
import net.i2p.crypto.eddsa.EdDSAPrivateKey;
|
||||
import net.i2p.crypto.eddsa.EdDSAPublicKey;
|
||||
import net.i2p.crypto.eddsa.EdDSASecurityProvider;
|
||||
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable;
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec;
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec;
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;
|
||||
|
||||
import org.spongycastle.asn1.ASN1EncodableVector;
|
||||
import org.spongycastle.asn1.ASN1Integer;
|
||||
import org.spongycastle.asn1.DERSequence;
|
||||
|
|
@ -17,6 +26,7 @@ import java.math.BigInteger;
|
|||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.PrivateKey;
|
||||
|
|
@ -39,122 +49,225 @@ import javax.crypto.spec.SecretKeySpec;
|
|||
public class CardCrypto {
|
||||
static {
|
||||
Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
|
||||
Security.addProvider(new EdDSASecurityProvider());
|
||||
}
|
||||
|
||||
public enum Curve {secp256k1, ed25519}
|
||||
|
||||
public static PublicKey LoadPublicKey(Curve curve, byte[] publicKeyArray) throws Exception {
|
||||
if (publicKeyArray == null) throw new Exception("Public key not specified!");
|
||||
switch (curve) {
|
||||
case secp256k1: {
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
KeyFactory factory = KeyFactory.getInstance("EC", "SC");
|
||||
|
||||
ECPoint p1 = spec.getCurve().decodePoint(publicKeyArray);
|
||||
ECPublicKeySpec keySpec = new ECPublicKeySpec(p1, spec);
|
||||
|
||||
return factory.generatePublic(keySpec);
|
||||
}
|
||||
case ed25519: {
|
||||
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);
|
||||
EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(publicKeyArray, spec);
|
||||
return new EdDSAPublicKey(pubKey);
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Exception(curve.toString() + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static PublicKey LoadPublicKey(byte[] publicKeyArray) throws Exception {
|
||||
if( publicKeyArray==null ) throw new Exception("Public key not specified!");
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
KeyFactory factory = KeyFactory.getInstance("EC", "SC");
|
||||
return LoadPublicKey(Curve.secp256k1, publicKeyArray);
|
||||
}
|
||||
|
||||
ECPoint p1 = spec.getCurve().decodePoint(publicKeyArray);
|
||||
ECPublicKeySpec keySpec = new ECPublicKeySpec(p1, spec);
|
||||
public static boolean VerifySignature(Curve curve, byte[] publicKeyArray, byte[] data, byte[] signature) throws Exception {
|
||||
switch (curve) {
|
||||
case secp256k1: {
|
||||
Signature signatureInstance = Signature.getInstance("SHA256withECDSA");
|
||||
PublicKey publicKey = LoadPublicKey(publicKeyArray);
|
||||
signatureInstance.initVerify(publicKey);
|
||||
signatureInstance.update(data);
|
||||
|
||||
return factory.generatePublic(keySpec);
|
||||
ASN1EncodableVector v = new ASN1EncodableVector();
|
||||
int size = signature.length / 2;
|
||||
v.add(/*r*/new ASN1Integer(new BigInteger(1, Arrays.copyOfRange(signature, 0, size))));
|
||||
v.add(/*s*/new ASN1Integer(new BigInteger(1, Arrays.copyOfRange(signature, size, size * 2))));
|
||||
byte[] sigDer = new DERSequence(v).getEncoded();
|
||||
|
||||
return signatureInstance.verify(sigDer);
|
||||
}
|
||||
case ed25519: {
|
||||
data = Util.calculateSHA512(data);
|
||||
PublicKey publicKey = LoadPublicKey(curve, publicKeyArray);
|
||||
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);
|
||||
Signature signatureInstance = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm()));
|
||||
signatureInstance.initVerify(publicKey);
|
||||
|
||||
signatureInstance.update(data);
|
||||
|
||||
return signatureInstance.verify(signature);
|
||||
}
|
||||
default:
|
||||
throw new Exception(curve.toString() + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean VerifySignature(byte[] publicKeyArray, byte[] data, byte[] signature) throws Exception {
|
||||
Signature signatureInstance = Signature.getInstance("SHA256withECDSA");
|
||||
PublicKey publicKey = LoadPublicKey(publicKeyArray);
|
||||
signatureInstance.initVerify(publicKey);
|
||||
signatureInstance.update(data);
|
||||
|
||||
ASN1EncodableVector v = new ASN1EncodableVector();
|
||||
int size = signature.length / 2;
|
||||
v.add(/*r*/new ASN1Integer(new BigInteger(1, Arrays.copyOfRange(signature, 0, size))));
|
||||
v.add(/*s*/new ASN1Integer(new BigInteger(1, Arrays.copyOfRange(signature, size, size * 2))));
|
||||
byte[] sigDer = new DERSequence(v).getEncoded();
|
||||
|
||||
return signatureInstance.verify(sigDer);
|
||||
return VerifySignature(Curve.secp256k1, publicKeyArray, data, signature);
|
||||
}
|
||||
|
||||
public static boolean VerifySignature(String curveID, byte[] publicKeyArray, byte[] data, byte[] signature) throws Exception {
|
||||
Curve curve;
|
||||
try {
|
||||
curve = Curve.valueOf(curveID);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Card EC curve (" + curveID + ") isn't supported!");
|
||||
}
|
||||
return VerifySignature(curve, publicKeyArray, data, signature);
|
||||
}
|
||||
|
||||
|
||||
public static byte[] Signature(Curve curve, byte[] privateKeyArray, byte[] data) throws Exception {
|
||||
switch (curve) {
|
||||
case secp256k1: {
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
KeyFactory factory = KeyFactory.getInstance("EC", "SC");
|
||||
|
||||
ECPrivateKeySpec keySpecP = new ECPrivateKeySpec(new BigInteger(1, privateKeyArray), spec);
|
||||
|
||||
Signature signature = Signature.getInstance("SHA256withECDSA");
|
||||
|
||||
PrivateKey privateKey = factory.generatePrivate(keySpecP);
|
||||
signature.initSign(privateKey);
|
||||
signature.update(data);
|
||||
byte[] enc = signature.sign();
|
||||
|
||||
if (enc[0] != 0x30) throw new Exception("bad encoding 1");
|
||||
if ((enc[1] & 0x80) != 0) throw new Exception("unsupported length encoding 1");
|
||||
if (enc[2] != 0x02) throw new Exception("bad encoding 2");
|
||||
if ((enc[3] & 0x80) != 0) throw new Exception("unsupported length encoding 2");
|
||||
int rLength = enc[3];
|
||||
|
||||
if (enc[4 + rLength] != 0x02) throw new Exception("bad encoding 3");
|
||||
if ((enc[5 + rLength] & 0x80) != 0) throw new Exception("unsupported length encoding 3");
|
||||
int sLength = enc[5 + rLength];
|
||||
|
||||
|
||||
int sPos = 6 + rLength;
|
||||
byte[] res = new byte[64];
|
||||
if (rLength <= 32) {
|
||||
System.arraycopy(enc, 4, res, 32 - rLength, rLength);
|
||||
rLength = 32;
|
||||
} else if (rLength == 33 && enc[4] == 0) {
|
||||
rLength--;
|
||||
System.arraycopy(enc, 5, res, 0, rLength);
|
||||
} else {
|
||||
Log.e("cardCrypto", "r-length:" + String.valueOf(rLength));
|
||||
Log.e("cardCrypto", "s-length:" + String.valueOf(sLength));
|
||||
Log.e("cardCrypto", "enc:" + Util.bytesToHex(enc));
|
||||
throw new Exception("unsupported r-length - r-length:" + String.valueOf(rLength) + ",s-length:" + String.valueOf(sLength) + ",enc:" + Util.bytesToHex(enc));
|
||||
}
|
||||
if (sLength <= 32) {
|
||||
System.arraycopy(enc, sPos, res, rLength + 32 - sLength, sLength);
|
||||
sLength = 32;
|
||||
} else if (sLength == 33 && enc[sPos] == 0) {
|
||||
System.arraycopy(enc, sPos + 1, res, rLength, sLength - 1);
|
||||
} else {
|
||||
Log.e("cardCrypto", "s-length:" + String.valueOf(sLength));
|
||||
Log.e("cardCrypto", "r-length:" + String.valueOf(rLength));
|
||||
Log.e("cardCrypto", "enc:" + Util.bytesToHex(enc));
|
||||
throw new Exception("unsupported s-length - r-length:" + String.valueOf(rLength) + ",s-length:" + String.valueOf(sLength) + ",enc:" + Util.bytesToHex(enc));
|
||||
}
|
||||
|
||||
if (!VerifySignature(GeneratePublicKey(privateKeyArray), data, res)) {
|
||||
throw new Exception("Signature self verify failed - r-length:" + String.valueOf(rLength) + ",s-length:" + String.valueOf(sLength) + ",enc:" + Util.bytesToHex(enc) + ",res:" + Util.bytesToHex(res));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
case ed25519: {
|
||||
data = Util.calculateSHA512(data);
|
||||
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);
|
||||
//Signature sgr = Signature.getInstance("EdDSA", "I2P");
|
||||
Signature signatureInstance = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm()));
|
||||
|
||||
EdDSAPrivateKeySpec privateKeySpec = new EdDSAPrivateKeySpec(privateKeyArray, spec);
|
||||
PrivateKey privateKey = new EdDSAPrivateKey(privateKeySpec);
|
||||
|
||||
signatureInstance.initSign(privateKey);
|
||||
signatureInstance.update(data);
|
||||
|
||||
return signatureInstance.sign();
|
||||
}
|
||||
default:
|
||||
throw new Exception(curve.toString() + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Signature(byte[] privateKeyArray, byte[] data) throws Exception {
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
KeyFactory factory = KeyFactory.getInstance("EC", "SC");
|
||||
|
||||
ECPrivateKeySpec keySpecP = new ECPrivateKeySpec(new BigInteger(1,privateKeyArray), spec);
|
||||
|
||||
Signature signature = Signature.getInstance("SHA256withECDSA");
|
||||
|
||||
PrivateKey privateKey = factory.generatePrivate(keySpecP);
|
||||
signature.initSign(privateKey);
|
||||
signature.update(data);
|
||||
byte[] enc = signature.sign();
|
||||
|
||||
if (enc[0] != 0x30) throw new Exception("bad encoding 1");
|
||||
if ((enc[1] & 0x80) != 0) throw new Exception("unsupported length encoding 1");
|
||||
if (enc[2] != 0x02) throw new Exception("bad encoding 2");
|
||||
if ((enc[3] & 0x80) != 0) throw new Exception("unsupported length encoding 2");
|
||||
int rLength = enc[3];
|
||||
|
||||
if (enc[4 + rLength] != 0x02) throw new Exception("bad encoding 3");
|
||||
if ((enc[5 + rLength] & 0x80) != 0) throw new Exception("unsupported length encoding 3");
|
||||
int sLength = enc[5 + rLength];
|
||||
|
||||
|
||||
int sPos = 6 + rLength;
|
||||
byte[] res = new byte[64];
|
||||
if (rLength <= 32) {
|
||||
System.arraycopy(enc, 4, res, 32-rLength, rLength);
|
||||
rLength=32;
|
||||
} else if (rLength == 33 && enc[4] == 0) {
|
||||
rLength--;
|
||||
System.arraycopy(enc, 5, res, 0, rLength);
|
||||
} else {
|
||||
Log.e("cardCrypto","r-length:" + String.valueOf(rLength));
|
||||
Log.e("cardCrypto","s-length:" + String.valueOf(sLength));
|
||||
Log.e("cardCrypto","enc:" + Util.bytesToHex(enc));
|
||||
throw new Exception("unsupported r-length - r-length:" + String.valueOf(rLength)+",s-length:" + String.valueOf(sLength)+",enc:" +Util.bytesToHex(enc));
|
||||
}
|
||||
if (sLength <= 32) {
|
||||
System.arraycopy(enc, sPos, res, rLength+32-sLength, sLength);
|
||||
sLength=32;
|
||||
} else if (sLength == 33 && enc[sPos] == 0) {
|
||||
System.arraycopy(enc, sPos + 1, res, rLength, sLength - 1);
|
||||
} else {
|
||||
Log.e("cardCrypto","s-length:" + String.valueOf(sLength));
|
||||
Log.e("cardCrypto","r-length:" + String.valueOf(rLength));
|
||||
Log.e("cardCrypto","enc:" +Util.bytesToHex(enc));
|
||||
throw new Exception("unsupported s-length - r-length:" + String.valueOf(rLength)+",s-length:" + String.valueOf(sLength)+",enc:" +Util.bytesToHex(enc));
|
||||
}
|
||||
|
||||
if(!VerifySignature(GeneratePublicKey(privateKeyArray), data, res))
|
||||
{
|
||||
throw new Exception("Signature self verify failed - r-length:" + String.valueOf(rLength)+",s-length:" + String.valueOf(sLength)+",enc:" +Util.bytesToHex(enc)+",res:"+Util.bytesToHex(res));
|
||||
}
|
||||
|
||||
return res;
|
||||
return Signature(Curve.secp256k1, privateKeyArray, data);
|
||||
}
|
||||
|
||||
public static byte[] GeneratePublicKey(byte[] privateKeyArray) throws NoSuchProviderException, NoSuchAlgorithmException {
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
public static byte[] GeneratePublicKey(Curve curve, byte[] privateKeyArray) throws Exception {
|
||||
switch (curve) {
|
||||
case secp256k1: {
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
|
||||
|
||||
byte[] publicKeyArray = spec.getG().multiply(new BigInteger(1,privateKeyArray)).getEncoded(false);
|
||||
byte[] publicKeyArray = spec.getG().multiply(new BigInteger(1, privateKeyArray)).getEncoded(false);
|
||||
|
||||
return publicKeyArray;
|
||||
return publicKeyArray;
|
||||
}
|
||||
case ed25519: {
|
||||
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);
|
||||
|
||||
EdDSAPrivateKeySpec privateKeySpec = new EdDSAPrivateKeySpec(privateKeyArray, spec);
|
||||
EdDSAPublicKeySpec publicKeySpec = new EdDSAPublicKeySpec(privateKeySpec.getA(), spec);
|
||||
EdDSAPublicKey publicKey = new EdDSAPublicKey(publicKeySpec);
|
||||
return publicKey.getAbyte();
|
||||
}
|
||||
default:
|
||||
throw new Exception(curve.toString() + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static byte[] GeneratePublicKey(byte[] privateKeyArray) throws Exception {
|
||||
return GeneratePublicKey(Curve.secp256k1, privateKeyArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the PBKDF2 hash of a password.
|
||||
* Computes the PBKDF2 hash of a password.
|
||||
*
|
||||
* @param password the password to hash.
|
||||
* @param salt the salt
|
||||
* @param iterations the iteration count (slowness factor)
|
||||
* @return the PBDKF2 hash of the password
|
||||
* @param password the password to hash.
|
||||
* @param salt the salt
|
||||
* @param iterations the iteration count (slowness factor)
|
||||
* @return the PBDKF2 hash of the password
|
||||
*/
|
||||
public static byte[] pbkdf2(byte[] password, byte[] salt, int iterations)
|
||||
throws InvalidKeyException {
|
||||
return PBKDF2.deriveKey(password, salt, iterations);
|
||||
}
|
||||
|
||||
public static byte[] Encrypt(byte[] key, byte[] data) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException
|
||||
{
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES/CBC/PKCS7PADDING");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7PADDING", "BC");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16]));
|
||||
byte[] mEncryptedData = cipher.doFinal(data);
|
||||
return mEncryptedData;
|
||||
public static byte[] Encrypt(byte[] key, byte[] data, boolean UsePKCS7) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
|
||||
if (UsePKCS7) {
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES/CBC/PKCS7PADDING");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7PADDING", "SC");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16]));
|
||||
byte[] mEncryptedData = cipher.doFinal(data);
|
||||
return mEncryptedData;
|
||||
} else {
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES/CBC/NOPADDING");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/NOPADDING", "SC");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(new byte[16]));
|
||||
byte[] mEncryptedData = cipher.doFinal(data);
|
||||
return mEncryptedData;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Encrypt(byte[] key, byte[] data) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
|
||||
return Encrypt(key, data, true);
|
||||
}
|
||||
|
||||
public static byte[] Decrypt(byte[] key, byte[] data, boolean UsePKCS7)
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ public class CardProtocol {
|
|||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param reader - NFC Reader interface
|
||||
* @param card - TangemCard object, stored data from previous reading or null for reading a card for the first time
|
||||
* @param notifications - UI notification callbacks
|
||||
|
|
@ -151,11 +152,10 @@ public class CardProtocol {
|
|||
public CardProtocol(NfcReader reader, TangemCard card, Notifications notifications) {
|
||||
mIsoDep = reader;
|
||||
mNotifications = notifications;
|
||||
if (card != null)
|
||||
{
|
||||
if (card != null) {
|
||||
mPIN = card.getPIN();
|
||||
mCard = card;
|
||||
}else{
|
||||
} else {
|
||||
mPIN = null;
|
||||
mCard = new TangemCard(Util.byteArrayToHexString(mIsoDep.getId()));
|
||||
}
|
||||
|
|
@ -177,6 +177,7 @@ public class CardProtocol {
|
|||
public TangemException_TagLost() {
|
||||
super("Tag lost");
|
||||
}
|
||||
|
||||
public TangemException_TagLost(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
@ -231,7 +232,7 @@ public class CardProtocol {
|
|||
* @return UID byte array
|
||||
*/
|
||||
public byte[] GetUID() {
|
||||
if (mIsoDep == null ) return null;
|
||||
if (mIsoDep == null) return null;
|
||||
return mIsoDep.getId();
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +240,7 @@ public class CardProtocol {
|
|||
* Return ISO 14443-3 tag reading timeout
|
||||
*/
|
||||
public int getTimeout() {
|
||||
if (mIsoDep == null ) return 60000;
|
||||
if (mIsoDep == null) return 60000;
|
||||
return mIsoDep.getTimeout();
|
||||
}
|
||||
|
||||
|
|
@ -410,10 +411,10 @@ public class CardProtocol {
|
|||
* Should have a prior opened encryption session if encryption is used
|
||||
* See [1] 4
|
||||
*
|
||||
* @param cmdApdu - APDU command to send
|
||||
* @param breakOnNeedPause - Specifies what to do when the card requests a security delay (interrupt transfer or wait till the end of the delay )
|
||||
* @return - response APDU
|
||||
* @throws Exception - if something went wrong
|
||||
* @param cmdApdu - APDU command to send
|
||||
* @param breakOnNeedPause - Specifies what to do when the card requests a security delay (interrupt transfer or wait till the end of the delay )
|
||||
* @return - response APDU
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
private ResponseApdu SendAndReceive(CommandApdu cmdApdu, boolean breakOnNeedPause) throws Exception {
|
||||
if (mCard.encryptionMode != TangemCard.EncryptionMode.None) {
|
||||
|
|
@ -548,8 +549,7 @@ public class CardProtocol {
|
|||
return readResult != null;
|
||||
}
|
||||
|
||||
public TLVList getReadResult()
|
||||
{
|
||||
public TLVList getReadResult() {
|
||||
return readResult;
|
||||
}
|
||||
|
||||
|
|
@ -707,12 +707,13 @@ public class CardProtocol {
|
|||
TLVList checkResult = run_CheckWallet();
|
||||
if (checkResult == null) return;
|
||||
|
||||
TLV tlvCurveID = readResult.getTLV(TLV.Tag.TAG_CurveID);
|
||||
TLV tlvPublicKey = readResult.getTLV(TLV.Tag.TAG_Wallet_PublicKey);
|
||||
TLV tlvChallenge = checkResult.getTLV(TLV.Tag.TAG_Challenge);
|
||||
TLV tlvSalt = checkResult.getTLV(TLV.Tag.TAG_Salt);
|
||||
TLV tlvSignature = checkResult.getTLV(TLV.Tag.TAG_Signature);
|
||||
|
||||
if (tlvPublicKey == null || tlvChallenge == null || tlvSalt == null || tlvSignature == null) {
|
||||
if (tlvCurveID == null || tlvPublicKey == null || tlvChallenge == null || tlvSalt == null || tlvSignature == null) {
|
||||
throw new TangemException("Not all data read, can't check signature!");
|
||||
}
|
||||
|
||||
|
|
@ -721,7 +722,7 @@ public class CardProtocol {
|
|||
bs.write(tlvSalt.Value);
|
||||
byte[] dataArray = bs.toByteArray();
|
||||
|
||||
if (CardCrypto.VerifySignature(tlvPublicKey.Value, dataArray, tlvSignature.Value)) {
|
||||
if (CardCrypto.VerifySignature(tlvCurveID.getAsString(), tlvPublicKey.Value, dataArray, tlvSignature.Value)) {
|
||||
Log.i(logTag, "Signature verification OK");
|
||||
mCard.setWalletPublicKeyValid(true);
|
||||
} else {
|
||||
|
|
@ -810,16 +811,17 @@ public class CardProtocol {
|
|||
/**
|
||||
* SIGN command to sign hashes - SigningMethod=0,2,4 (see {@link TangemCard.SigningMethod})
|
||||
* See [1] 8.6
|
||||
* @param PIN2 - PIN2 code to confirm operation
|
||||
* @param hashes - array of digests to sign (max 10 digest at a time)
|
||||
*
|
||||
* @param PIN2 - PIN2 code to confirm operation
|
||||
* @param hashes - array of digests to sign (max 10 digest at a time)
|
||||
* @param issuerTransactionSignature - signature of hashes, if card need issuer validation before sign (for SigningMethod=2)
|
||||
* @param issuerData - new issuerData to write on card (only for SigningMethod=4, null for other)
|
||||
* @param issuerDataSignature - signature of issuerData, if issuerData specified(for SigningMethod=4)
|
||||
* @param issuerData - new issuerData to write on card (only for SigningMethod=4, null for other)
|
||||
* @param issuerDataSignature - signature of issuerData, if issuerData specified(for SigningMethod=4)
|
||||
* @return TLVList with card answer contained wallet signatures of digests from hashes array (in case of success)
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
public TLVList run_SignHashes(String PIN2, byte[][] hashes, byte[] issuerTransactionSignature, byte[] issuerData, byte[] issuerDataSignature) throws Exception {
|
||||
if ( mCard.getSigningMethod()!=TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer && mCard.getSigningMethod()!=TangemCard.SigningMethod.Sign_Hash ){
|
||||
if (mCard.getSigningMethod() != TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer && mCard.getSigningMethod() != TangemCard.SigningMethod.Sign_Hash) {
|
||||
throw new TangemException("Card don't support signing hashes!");
|
||||
}
|
||||
|
||||
|
|
@ -835,19 +837,19 @@ public class CardProtocol {
|
|||
rqApdu.addTLV_U8(TLV.Tag.TAG_TrOut_HashSize, hashes[0].length);
|
||||
rqApdu.addTLV(TLV.Tag.TAG_TrOut_Hash, bs.toByteArray());
|
||||
if (issuerData != null) {
|
||||
if ( mCard.getSigningMethod()!=TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer_And_WriteIssuerData )
|
||||
if (mCard.getSigningMethod() != TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer_And_WriteIssuerData)
|
||||
throw new TangemException("Card don't support simultaneous sign with write issuer data!");
|
||||
|
||||
if (issuerDataSignature == null )
|
||||
if (issuerDataSignature == null)
|
||||
throw new TangemException("Card require issuer validation before write issuer data");
|
||||
bs.write(issuerData);
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Data, issuerData);
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Data_Signature, issuerDataSignature);
|
||||
}
|
||||
if (issuerTransactionSignature!=null) {
|
||||
if (issuerTransactionSignature != null) {
|
||||
//byte[] issuerSignature = CardCrypto.Signature(issuer.getPrivateTransactionKey(), bs.toByteArray());
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Transaction_Signature, issuerTransactionSignature);
|
||||
}else if ( mCard.getSigningMethod()==TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer ){
|
||||
} else if (mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer) {
|
||||
throw new TangemException("Card require issuer validation before sign the transaction!");
|
||||
}
|
||||
|
||||
|
|
@ -875,12 +877,13 @@ public class CardProtocol {
|
|||
/**
|
||||
* SIGN raw tx - SigningMethod=1 (see {@link TangemCard.SigningMethod})
|
||||
* See [1] 8.6
|
||||
* @param PIN2 - PIN2 code to confirm operation
|
||||
* @param hashAlgID - name of hash alg, used for signature
|
||||
* @param bTxOutData - part of raw transaction to sign
|
||||
*
|
||||
* @param PIN2 - PIN2 code to confirm operation
|
||||
* @param hashAlgID - name of hash alg, used for signature
|
||||
* @param bTxOutData - part of raw transaction to sign
|
||||
* @param issuerTransactionSignature - signature of hashes, if card need issuer validation before sign (for SigningMethod=2)
|
||||
* @param issuerData - new issuerData to write on card (only for SigningMethod=4, null for other)
|
||||
* @param issuerDataSignature - signature of issuerData, if issuerData specified(for SigningMethod=4)
|
||||
* @param issuerData - new issuerData to write on card (only for SigningMethod=4, null for other)
|
||||
* @param issuerDataSignature - signature of issuerData, if issuerData specified(for SigningMethod=4)
|
||||
* @return TLVList with card answer contained wallet signatures of bTxOutData(in case of success)
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
|
|
@ -897,18 +900,18 @@ public class CardProtocol {
|
|||
bs.write(bTxOutData);
|
||||
|
||||
if (issuerData != null) {
|
||||
if ( mCard.getSigningMethod()!=TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer_And_WriteIssuerData )
|
||||
if (mCard.getSigningMethod() != TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer_And_WriteIssuerData)
|
||||
throw new TangemException("Card don't support simultaneous sign with write issuer data!");
|
||||
|
||||
if (issuerDataSignature == null )
|
||||
if (issuerDataSignature == null)
|
||||
throw new TangemException("Card require issuer validation before write issuer data");
|
||||
bs.write(issuerData);
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Data, issuerData);
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Data_Signature, issuerDataSignature);
|
||||
}
|
||||
if (issuerTransactionSignature!=null) {
|
||||
if (issuerTransactionSignature != null) {
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Transaction_Signature, issuerTransactionSignature);
|
||||
}else if ( mCard.getSigningMethod()==TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer ){
|
||||
} else if (mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer) {
|
||||
throw new TangemException("Card require issuer validation before sign the transaction!");
|
||||
}
|
||||
|
||||
|
|
@ -940,10 +943,11 @@ public class CardProtocol {
|
|||
* VERIFY_CODE command internally reads a segment of COS binary code beginning at Code_Page_Address and having length of [64 x Code_Page_Count] bytes.
|
||||
* Then it appends Challenge to the code segment, calculates resulting hash and returns it in the response.
|
||||
* The application needs to ensure that returned hash coincides with the one stored in the hash library (see {@see Firmwares}).
|
||||
* @param hashAlgID - ‘sha-256’, ‘sha-1’, ‘sha-224’, ‘sha-384’, ‘sha-512’, ‘crc-16’
|
||||
*
|
||||
* @param hashAlgID - ‘sha-256’, ‘sha-1’, ‘sha-224’, ‘sha-384’, ‘sha-512’, ‘crc-16’
|
||||
* @param codePageAddress - Value from 0 to ~3000, take from {@see Firmwares}
|
||||
* @param codePageCount - Number of 32-byte pages to read: from 1 to 5, take from {@see Firmwares}
|
||||
* @param challenge - Additional challenge value from 1 to 10, take from {@see Firmwares}
|
||||
* @param codePageCount - Number of 32-byte pages to read: from 1 to 5, take from {@see Firmwares}
|
||||
* @param challenge - Additional challenge value from 1 to 10, take from {@see Firmwares}
|
||||
* @return digest bytes to compare with one stored in {@see Firmwares}
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
|
|
@ -979,6 +983,7 @@ public class CardProtocol {
|
|||
* Card_Validation_Counter and its signature to issuer’s card validation back-end (server). The server should verify the signature and update Card_Validation_Counter value if
|
||||
* previous value is less than the new one. If the server reveals that submitted Card_Validation_Counter value is less than previous value, then the card having this CID is
|
||||
* deemed compromised and should not be accepted by the application.
|
||||
*
|
||||
* @param PIN2 - PIN2 code to confirm operation
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
|
|
@ -1011,12 +1016,13 @@ public class CardProtocol {
|
|||
* This command re-writes Issuer_Data data block (max 512 bytes) and its issuer’s signature.
|
||||
* Issuer_Data is never changed or parsed from within the Tangem COS. The issuer defines purpose of use, format and payload of Issuer_Data.
|
||||
* For example, this field may contain information about wallet balance signed by the issuer or additional issuer’s attestation data
|
||||
* @param issuerData - new issuerData
|
||||
*
|
||||
* @param issuerData - new issuerData
|
||||
* @param issuerSignature - signature of issuerData with IssuerDataKey
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
public void run_WriteIssuerData(byte[] issuerData, byte[] issuerSignature) throws Exception {
|
||||
if( readResult==null ) throw new TangemException("Before run_VerifyCard execute run_Read card first!");
|
||||
if (readResult == null) throw new TangemException("Before run_VerifyCard execute run_Read card first!");
|
||||
|
||||
CommandApdu rqApdu = StartPrepareCommand(INS.WriteIssuerData);
|
||||
rqApdu.addTLV(TLV.Tag.TAG_Issuer_Data, issuerData);
|
||||
|
|
@ -1037,6 +1043,7 @@ public class CardProtocol {
|
|||
* GET_ISSUER_DATA command and verify verify issuer signature of returned data
|
||||
* See [1] 3.3, 8.7
|
||||
* This command returns Issuer_Data data block and its issuer’s signature.
|
||||
*
|
||||
* @return TLVList with issuerData (if success read and verify)
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
|
|
@ -1084,6 +1091,7 @@ public class CardProtocol {
|
|||
* Execute consecutive READ commands with increasing encryption level from EncryptionMode.None to EncryptionMode.Strong, see {@link TangemCard.EncryptionMode}
|
||||
* If card requires stricter encryption level it returns SW.NEED_ENCRYPTION status word
|
||||
* Once READ is successfully executed - save answer to {@see readResult}, save current PIN and encryption mode to {@link TangemCard} and return
|
||||
*
|
||||
* @throws Exception - if something went wrong
|
||||
*/
|
||||
public void run_GetSupportedEncryption() throws Exception {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.tangem.tangemcard.data.external.CardDataSubstitutionProvider;
|
|||
import com.tangem.tangemcard.data.Manufacturer;
|
||||
import com.tangem.tangemcard.data.external.PINsProvider;
|
||||
import com.tangem.tangemcard.data.TangemCard;
|
||||
import com.tangem.tangemcard.reader.CardCrypto;
|
||||
import com.tangem.tangemcard.reader.CardProtocol;
|
||||
import com.tangem.tangemcard.reader.NfcReader;
|
||||
import com.tangem.tangemcard.reader.TLV;
|
||||
|
|
@ -20,6 +21,8 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static com.tangem.tangemcard.reader.CardCrypto.Curve.secp256k1;
|
||||
|
||||
/**
|
||||
* Base class for card communication task
|
||||
*/
|
||||
|
|
@ -29,7 +32,7 @@ public class CustomReadCardTask extends Thread {
|
|||
protected NfcReader mIsoDep;
|
||||
protected CardProtocol.Notifications mNotifications;
|
||||
protected boolean isCancelled = false;
|
||||
protected TangemCard mCard ;
|
||||
protected TangemCard mCard;
|
||||
CardDataSubstitutionProvider localStorage;
|
||||
PINsProvider pinsProvider;
|
||||
CardProtocol protocol;
|
||||
|
|
@ -48,9 +51,9 @@ public class CustomReadCardTask extends Thread {
|
|||
public CustomReadCardTask(TangemCard card, NfcReader reader, CardDataSubstitutionProvider cardDataSubstitutionProvider, PINsProvider pinsProvider, CardProtocol.Notifications notifications) {
|
||||
mIsoDep = reader;
|
||||
mNotifications = notifications;
|
||||
localStorage= cardDataSubstitutionProvider;
|
||||
this.pinsProvider=pinsProvider;
|
||||
mCard=card;
|
||||
localStorage = cardDataSubstitutionProvider;
|
||||
this.pinsProvider = pinsProvider;
|
||||
mCard = card;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +112,7 @@ public class CustomReadCardTask extends Thread {
|
|||
* @throws CardProtocol.TangemException - if something went wrong
|
||||
*/
|
||||
public void parseReadResult() throws CardProtocol.TangemException {
|
||||
if( mCard==null ) mCard=protocol.getCard();
|
||||
if (mCard == null) mCard = protocol.getCard();
|
||||
// These tags always present in the parsed response: TAG_Status, TAG_CID, TAG_Manufacture_ID, TAG_Health, TAG_Firmware
|
||||
TLV tlvStatus = protocol.getReadResult().getTLV(TLV.Tag.TAG_Status);
|
||||
mCard.setStatus(TangemCard.Status.fromCode(Util.byteArrayToInt(tlvStatus.Value)));
|
||||
|
|
@ -199,7 +202,7 @@ public class CustomReadCardTask extends Thread {
|
|||
mCard.setContractAddress("0x0c056b0cda0763cc14b8b2d6c02465c91e33ec72");
|
||||
} else {
|
||||
//CardDataSubstitutionProvider localStorage = new CardDataSubstitutionProvider(mContext);
|
||||
if( localStorage!=null ) localStorage.applySubstitution(mCard);
|
||||
if (localStorage != null) localStorage.applySubstitution(mCard);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Can't apply card data substitution");
|
||||
|
|
@ -245,15 +248,26 @@ public class CustomReadCardTask extends Thread {
|
|||
if (mCard.getStatus() == TangemCard.Status.Loaded) {
|
||||
|
||||
TLV tlvPublicKey = protocol.getReadResult().getTLV(TLV.Tag.TAG_Wallet_PublicKey);
|
||||
String curveID = protocol.getReadResult().getTLV(TLV.Tag.TAG_CurveID).getAsString();
|
||||
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
ECPoint p1 = spec.getCurve().decodePoint(tlvPublicKey.Value);
|
||||
CardCrypto.Curve curve = CardCrypto.Curve.valueOf(curveID);
|
||||
switch (curve) {
|
||||
case secp256k1:
|
||||
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
|
||||
ECPoint p1 = spec.getCurve().decodePoint(tlvPublicKey.Value);
|
||||
|
||||
byte pkUncompressed[] = p1.getEncoded(false);
|
||||
byte pkUncompressed[] = p1.getEncoded(false);
|
||||
|
||||
byte pkCompresses[] = p1.getEncoded(true);
|
||||
mCard.setWalletPublicKey(pkUncompressed);
|
||||
mCard.setWalletPublicKeyRar(pkCompresses);
|
||||
byte pkCompresses[] = p1.getEncoded(true);
|
||||
mCard.setWalletPublicKey(pkUncompressed);
|
||||
mCard.setWalletPublicKeyRar(pkCompresses);
|
||||
break;
|
||||
case ed25519:
|
||||
mCard.setWalletPublicKey(tlvPublicKey.Value);
|
||||
mCard.setWalletPublicKeyRar(tlvPublicKey.Value);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
mCard.setRemainingSignatures(protocol.getReadResult().getTagAsInt(TLV.Tag.TAG_RemainingSignatures));
|
||||
|
||||
|
|
@ -363,7 +377,7 @@ public class CustomReadCardTask extends Thread {
|
|||
protocol.setPIN(PIN);
|
||||
protocol.run_Read();
|
||||
pinsProvider.setLastUsedPIN(PIN);
|
||||
if (!Arrays.equals(mCard.getCID(),protocol.getReadResult().getTLV(TLV.Tag.TAG_CardID).Value)) {
|
||||
if (!Arrays.equals(mCard.getCID(), protocol.getReadResult().getTLV(TLV.Tag.TAG_CardID).Value)) {
|
||||
throw new CardProtocol.TangemException("Card must be the same. Reading attempt on different card!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ public class SignTask extends CustomReadCardTask {
|
|||
public static final String TAG = SignTask.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* Payment Engine request/notifications during sign process
|
||||
* Transaction Engine request/notifications during sign process
|
||||
*/
|
||||
public interface PaymentToSign {
|
||||
public interface TransactionToSign {
|
||||
boolean isSigningMethodSupported(TangemCard.SigningMethod signingMethod);
|
||||
|
||||
byte[][] getHashesToSign() throws Exception;
|
||||
|
|
@ -31,11 +31,11 @@ public class SignTask extends CustomReadCardTask {
|
|||
byte[] onSignCompleted(byte[] signature) throws Exception;
|
||||
}
|
||||
|
||||
private PaymentToSign paymentToSign;
|
||||
private TransactionToSign transactionToSign;
|
||||
|
||||
public SignTask(TangemCard card, NfcReader reader, CardDataSubstitutionProvider cardDataSubstitutionProvider, PINsProvider pinsProvider, CardProtocol.Notifications notifications, PaymentToSign paymentToSign) {
|
||||
public SignTask(TangemCard card, NfcReader reader, CardDataSubstitutionProvider cardDataSubstitutionProvider, PINsProvider pinsProvider, CardProtocol.Notifications notifications, TransactionToSign transactionToSign) {
|
||||
super(card, reader, cardDataSubstitutionProvider, pinsProvider, notifications);
|
||||
this.paymentToSign = paymentToSign;
|
||||
this.transactionToSign = transactionToSign;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -51,40 +51,40 @@ public class SignTask extends CustomReadCardTask {
|
|||
mNotifications.onReadWait(mCard.getPauseBeforePIN2());
|
||||
}
|
||||
|
||||
if (!paymentToSign.isSigningMethodSupported(mCard.getSigningMethod())) {
|
||||
if (!transactionToSign.isSigningMethodSupported(mCard.getSigningMethod())) {
|
||||
throw new CardProtocol.TangemException("Signing method isn't supported!");
|
||||
}
|
||||
|
||||
TLVList signResult;
|
||||
switch (mCard.getSigningMethod()) {
|
||||
case Sign_Hash:
|
||||
signResult = protocol.run_SignHashes(pinsProvider.getPIN2(), paymentToSign.getHashesToSign(), null, null, null);
|
||||
signResult = protocol.run_SignHashes(pinsProvider.getPIN2(), transactionToSign.getHashesToSign(), null, null, null);
|
||||
break;
|
||||
case Sign_Hash_Validated_By_Issuer:
|
||||
case Sign_Hash_Validated_By_Issuer_And_WriteIssuerData:
|
||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||
byte[][] hashes = paymentToSign.getHashesToSign();
|
||||
byte[][] hashes = transactionToSign.getHashesToSign();
|
||||
if (hashes.length > 10) throw new CardProtocol.TangemException("To much hashes in one transaction!");
|
||||
for (int i = 0; i < hashes.length; i++) {
|
||||
if (i != 0 && hashes[0].length != hashes[i].length)
|
||||
throw new CardProtocol.TangemException("Hashes length must be identical!");
|
||||
bs.write(hashes[i]);
|
||||
}
|
||||
signResult = protocol.run_SignHashes(pinsProvider.getPIN2(), hashes, paymentToSign.getIssuerTransactionSignature(bs.toByteArray()), null, null);
|
||||
signResult = protocol.run_SignHashes(pinsProvider.getPIN2(), hashes, transactionToSign.getIssuerTransactionSignature(bs.toByteArray()), null, null);
|
||||
break;
|
||||
case Sign_Raw:
|
||||
signResult = protocol.run_SignRaw(pinsProvider.getPIN2(), paymentToSign.getHashAlgToSign(), paymentToSign.getRawDataToSign(), null, null, null);
|
||||
signResult = protocol.run_SignRaw(pinsProvider.getPIN2(), transactionToSign.getHashAlgToSign(), transactionToSign.getRawDataToSign(), null, null, null);
|
||||
break;
|
||||
case Sign_Raw_Validated_By_Issuer:
|
||||
case Sign_Raw_Validated_By_Issuer_And_WriteIssuerData:
|
||||
byte[] txOut = paymentToSign.getRawDataToSign();
|
||||
signResult = protocol.run_SignRaw(pinsProvider.getPIN2(), paymentToSign.getHashAlgToSign(), txOut, paymentToSign.getIssuerTransactionSignature(txOut), null, null);
|
||||
byte[] txOut = transactionToSign.getRawDataToSign();
|
||||
signResult = protocol.run_SignRaw(pinsProvider.getPIN2(), transactionToSign.getHashAlgToSign(), txOut, transactionToSign.getIssuerTransactionSignature(txOut), null, null);
|
||||
break;
|
||||
default:
|
||||
throw new CardProtocol.TangemException("Signing method isn't supported!");
|
||||
}
|
||||
|
||||
paymentToSign.onSignCompleted(signResult.getTLV(TLV.Tag.TAG_Signature).Value);
|
||||
transactionToSign.onSignCompleted(signResult.getTLV(TLV.Tag.TAG_Signature).Value);
|
||||
mNotifications.onReadProgress(protocol, 100);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue