Updated on 2026-08-14
This commit is contained in:
parent
357cef6273
commit
857913f36a
7 changed files with 163 additions and 173 deletions
|
|
@ -26,7 +26,8 @@ public enum Blockchain {
|
|||
Stellar("XLM", "XLM", 1000000.0, R.drawable.ic_logo_stellar, "Stellar"),
|
||||
StellarTestNet("XLM/test", "XLM", 1000000.0, R.drawable.ic_logo_stellar, "Stellar Testnet"),
|
||||
StellarAsset("Asset", "XLM", 10000000.0, R.drawable.ic_logo_stellar, "Stellar"),
|
||||
Eos("EOS", "EOS", 10000.0, R.drawable.tangem2, "EOS");
|
||||
Eos("EOS", "EOS", 10000.0, R.drawable.tangem2, "EOS"),
|
||||
Ducatus("DUC", "DUC", 100000000.0, R.drawable.tangem2, "Ducatus");
|
||||
|
||||
Blockchain(String ID, String currency, double multiplier, int imageResource, String officialName) {
|
||||
mID = ID;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.data.network;
|
|||
|
||||
import com.tangem.data.network.model.InsightBody;
|
||||
import com.tangem.data.network.model.InsightResponse;
|
||||
import com.tangem.data.network.model.InsightUtxo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -18,7 +19,7 @@ public interface InsightApi {
|
|||
Call<InsightResponse> insightAddress(@Path("address") String address);
|
||||
|
||||
@GET(ServerApiInsight.INSIGHT_UNSPENT_OUTPUTS)
|
||||
Call<List<InsightResponse>> insightUnspent(@Path("address") String address);
|
||||
Call<List<InsightUtxo>> insightUnspent(@Path("address") String address);
|
||||
|
||||
@GET(ServerApiInsight.INSIGHT_TRANSACTION)
|
||||
Call<InsightResponse> insightTransaction(@Path("txId") String txId);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import com.tangem.data.network.model.InsightBody;
|
||||
import com.tangem.data.network.model.InsightResponse;
|
||||
import com.tangem.data.network.model.InsightUtxo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -18,11 +19,11 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class ServerApiInsight {
|
||||
private static String TAG = ServerApiInsight.class.getSimpleName();
|
||||
|
||||
public static final String INSIGHT_ADDRESS = "/addr/{address}";
|
||||
public static final String INSIGHT_UNSPENT_OUTPUTS = "/addr/{address}/utxo";
|
||||
public static final String INSIGHT_TRANSACTION = "/rawtx/{txId}";
|
||||
public static final String INSIGHT_FEE = "/utils/estimatefee?nbBlocks=2,3,6";
|
||||
public static final String INSIGHT_SEND = "/tx/send";
|
||||
public static final String INSIGHT_ADDRESS = "addr/{address}";
|
||||
public static final String INSIGHT_UNSPENT_OUTPUTS = "addr/{address}/utxo";
|
||||
public static final String INSIGHT_TRANSACTION = "rawtx/{txId}";
|
||||
public static final String INSIGHT_FEE = "utils/estimatefee?nbBlocks=2,3,6";
|
||||
public static final String INSIGHT_SEND = "tx/send";
|
||||
|
||||
private int requestsCount = 0;
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ public class ServerApiInsight {
|
|||
public interface ResponseListener {
|
||||
void onSuccess(String method, InsightResponse insightResponse);
|
||||
|
||||
void onSuccess(String method, List<InsightResponse> utxoList);
|
||||
void onSuccess(String method, List<InsightUtxo> utxoList);
|
||||
|
||||
void onFail(String method, String message);
|
||||
}
|
||||
|
|
@ -49,7 +50,7 @@ public class ServerApiInsight {
|
|||
|
||||
public void requestData(String method, String wallet, String tx) {
|
||||
requestsCount++;
|
||||
String insightURL = "http://130.185.109.17:3001/insigth-api"; //TODO: make random selection
|
||||
String insightURL = "https://insight.ducatus.io/insight-lite-api/"; //TODO: make random selection
|
||||
this.lastNode = insightURL; //TODO: show node instead of URL
|
||||
|
||||
Retrofit retrofitInsight = new Retrofit.Builder()
|
||||
|
|
@ -61,10 +62,10 @@ public class ServerApiInsight {
|
|||
InsightApi insightApi = retrofitInsight.create(InsightApi.class);
|
||||
|
||||
if (method.equals(INSIGHT_UNSPENT_OUTPUTS)) {
|
||||
Call<List<InsightResponse>> call = insightApi.insightUnspent(wallet);
|
||||
call.enqueue(new Callback<List<InsightResponse>>() {
|
||||
Call<List<InsightUtxo>> call = insightApi.insightUnspent(wallet);
|
||||
call.enqueue(new Callback<List<InsightUtxo>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<InsightResponse>> call, @NonNull Response<List<InsightResponse>> response) {
|
||||
public void onResponse(@NonNull Call<List<InsightUtxo>> call, @NonNull Response<List<InsightUtxo>> response) {
|
||||
requestsCount--;
|
||||
|
||||
if (response.code() == 200) {
|
||||
|
|
@ -77,7 +78,7 @@ public class ServerApiInsight {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<InsightResponse>> call, @NonNull Throwable t) {
|
||||
public void onFailure(@NonNull Call<List<InsightUtxo>> call, @NonNull Throwable t) {
|
||||
requestsCount--;
|
||||
responseListener.onFail(method, String.valueOf(t.getMessage()));
|
||||
Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
|
||||
|
|
@ -92,13 +93,9 @@ public class ServerApiInsight {
|
|||
call = insightApi.insightAddress(wallet);
|
||||
break;
|
||||
|
||||
case INSIGHT_TRANSACTION:
|
||||
call = insightApi.insightTransaction(tx);
|
||||
break;
|
||||
|
||||
case INSIGHT_FEE:
|
||||
call = insightApi.insightFee();
|
||||
break;
|
||||
// case INSIGHT_FEE:
|
||||
// call = insightApi.insightFee();
|
||||
// break;
|
||||
|
||||
case INSIGHT_SEND:
|
||||
call = insightApi.insightSend(new InsightBody(tx));
|
||||
|
|
|
|||
|
|
@ -12,27 +12,29 @@ data class InsightResponse(
|
|||
@SerializedName("addrStr")
|
||||
var addrStr: String = "",
|
||||
|
||||
// @SerializedName("2")
|
||||
// var fee2: String = "",
|
||||
//
|
||||
// @SerializedName("3")
|
||||
// var fee3: String = "",
|
||||
//
|
||||
// @SerializedName("6")
|
||||
// var fee6: String = "",
|
||||
|
||||
@SerializedName("error")
|
||||
var error: String = ""
|
||||
)
|
||||
|
||||
data class InsightUtxo(
|
||||
@SerializedName("txid")
|
||||
var txid: String = "",
|
||||
|
||||
@SerializedName("satoshis")
|
||||
var satoshis: Long? = null,
|
||||
|
||||
@SerializedName("height")
|
||||
var height: Int? = null,
|
||||
@SerializedName("vout")
|
||||
var vout: Int? = null,
|
||||
|
||||
@SerializedName("2")
|
||||
var fee2: String = "",
|
||||
|
||||
@SerializedName("3")
|
||||
var fee3: String = "",
|
||||
|
||||
@SerializedName("6")
|
||||
var fee6: String = "",
|
||||
|
||||
@SerializedName("rawtx")
|
||||
var rawtx: String = "",
|
||||
|
||||
@SerializedName("error")
|
||||
var error: String = ""
|
||||
@SerializedName("scriptPubKey")
|
||||
var scriptPubKey: String? = null
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue