Updated on 2026-08-14
This commit is contained in:
parent
9c4bd4f3b3
commit
344889cd48
4 changed files with 79 additions and 20 deletions
|
|
@ -280,10 +280,10 @@ public class ServerApiHelper {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
|
||||
Log.i(TAG, "getArtwork onResponse " + response.code());
|
||||
if (response.code() == 200 ) {
|
||||
if (response.code() == 200) {
|
||||
try {
|
||||
ResponseBody body=response.body();
|
||||
if ( body!= null) {
|
||||
ResponseBody body = response.body();
|
||||
if (body != null) {
|
||||
artworkListener.onArtwork(artworkId, body.byteStream(), updateDate);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -331,12 +331,11 @@ public class ServerApiHelper {
|
|||
for (RateInfoResponse rateInfoMode : rateInfoModelList) {
|
||||
if (rateInfoMode.getId().equals(cryptoId)) {
|
||||
rateInfoDataListener.onRateInfoDataData(rateInfoMode);
|
||||
Log.i(TAG, "rateInfoData " + cryptoId + " onResponse " + "200");
|
||||
Log.i(TAG, "rateInfoData " + cryptoId + " onResponse " + "200");
|
||||
}
|
||||
}
|
||||
} else
|
||||
Log.e(TAG, "rateInfoData " + cryptoId + " onResponse " + "Empty");
|
||||
|
||||
Log.e(TAG, "rateInfoData " + cryptoId + " onResponse " + "Empty");
|
||||
},
|
||||
// handle error
|
||||
Throwable::printStackTrace);
|
||||
|
|
@ -377,20 +376,20 @@ public class ServerApiHelper {
|
|||
public void onNext(ElectrumRequest electrumRequest) {
|
||||
if (electrumRequest.answerData != null) {
|
||||
electrumRequestDataListener.onElectrumRequestData(electrumRequest);
|
||||
Log.i(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onNext != null");
|
||||
} else {
|
||||
Log.i(TAG, "onNext ElectrumRequest == null");
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onNext == null");
|
||||
}
|
||||
Log.i(TAG, "onNext");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.i(TAG, "onError " + e.getMessage());
|
||||
Log.e(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onError " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.i(TAG, "onComplete");
|
||||
Log.i(TAG, "electrumRequestData " + electrumRequest.getMethod() + " onComplete");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -413,7 +412,7 @@ public class ServerApiHelper {
|
|||
Collections.addAll(result, electrumRequest);
|
||||
|
||||
try {
|
||||
Log.i(TAG, "host " + host + " !!!!!!!!!!!! " + "port " + String.valueOf(port));
|
||||
// Log.i(TAG, "host " + host + " !!!!!!!!!!!! " + "port " + String.valueOf(port));
|
||||
InetAddress serverAddress = InetAddress.getByName(host);
|
||||
Socket socket = new Socket();
|
||||
socket.setSoTimeout(5000);
|
||||
|
|
@ -497,7 +496,7 @@ public class ServerApiHelper {
|
|||
call.enqueue(new Callback<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
|
||||
Log.i(TAG, "lastVersion onResponse " + response.code());
|
||||
Log.i(TAG, "requestLastVersion onResponse " + response.code());
|
||||
if (response.code() == 200) {
|
||||
String stringResponse;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -158,6 +158,15 @@ public class ElectrumRequest {
|
|||
return request;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
try {
|
||||
return jsRequestData.getString("method");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean isMethod(String methodName) throws JSONException {
|
||||
return jsRequestData.getString("method").equals(methodName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.content.res.ColorStateList
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.nfc.tech.IsoDep
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.support.v4.app.Fragment
|
||||
|
|
@ -25,7 +24,6 @@ import com.google.zxing.WriterException
|
|||
import com.tangem.data.network.ServerApiHelper
|
||||
import com.tangem.data.network.model.InfuraResponse
|
||||
import com.tangem.data.network.request.ElectrumRequest
|
||||
import com.tangem.data.network.task.loaded_wallet.UpdateWalletInfoTask
|
||||
import com.tangem.data.nfc.VerifyCardTask
|
||||
import com.tangem.domain.cardReader.CardProtocol
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
|
|
@ -34,6 +32,7 @@ import com.tangem.presentation.activity.*
|
|||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.PINSwapWarningDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.util.BTCUtils
|
||||
import com.tangem.util.Util
|
||||
import com.tangem.util.UtilHelper
|
||||
import com.tangem.wallet.BuildConfig
|
||||
|
|
@ -259,11 +258,15 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val height = jsUnspent.getInt("height")
|
||||
val hash = jsUnspent.getString("tx_hash")
|
||||
if (height != -1) {
|
||||
val nodeAddress = engine.getNode(card)
|
||||
val nodePort = engine.getNodePort(card)
|
||||
val updateWalletInfoTask = UpdateWalletInfoTask(this, nodeAddress, nodePort)
|
||||
// loadedWallet.updateTasks.add(updateWalletInfoTask);
|
||||
updateWalletInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.getHeader(mWalletAddress, height.toString()), ElectrumRequest.getTransaction(mWalletAddress, hash))
|
||||
// val nodeAddress = engine.getNode(card)
|
||||
// val nodePort = engine.getNodePort(card)
|
||||
// val updateWalletInfoTask = UpdateWalletInfoTask(this, nodeAddress, nodePort)
|
||||
// // loadedWallet.updateTasks.add(updateWalletInfoTask);
|
||||
// updateWalletInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ElectrumRequest.getHeader(mWalletAddress, height.toString()), ElectrumRequest.getTransaction(mWalletAddress, hash))
|
||||
|
||||
|
||||
requestElectrum(card!!, ElectrumRequest.getHeader(mWalletAddress, height.toString()))
|
||||
requestElectrum(card!!, ElectrumRequest.getTransaction(mWalletAddress, hash))
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
|
|
@ -272,6 +275,54 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
}
|
||||
|
||||
if (it.isMethod(ElectrumRequest.METHOD_GetHeader)) {
|
||||
try {
|
||||
val jsHeader = it.result
|
||||
try {
|
||||
card!!.haedersInfo
|
||||
card!!.UpdateHeaderInfo(TangemCard.HeaderInfo(jsHeader.getInt("block_height"), jsHeader.getInt("timestamp")))
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
if (it.isMethod(ElectrumRequest.METHOD_GetTransaction)) {
|
||||
try {
|
||||
val txHash = it.txHash
|
||||
val raw = it.resultString
|
||||
val listTx = card!!.unspentTransactions
|
||||
for (tx in listTx) {
|
||||
if (tx.txID == txHash)
|
||||
tx.Raw = raw
|
||||
}
|
||||
val listHTx = card!!.historyTransactions
|
||||
for (tx in listHTx) {
|
||||
if (tx.txID == txHash) {
|
||||
tx.Raw = raw
|
||||
try {
|
||||
val prevHashes = BTCUtils.getPrevTX(raw)
|
||||
var isOur = false
|
||||
for (hash in prevHashes) {
|
||||
val checkID = BTCUtils.toHex(hash)
|
||||
for (txForCheck in listHTx) {
|
||||
if (txForCheck.txID == checkID)
|
||||
isOur = true
|
||||
}
|
||||
}
|
||||
tx.isInput = !isOur
|
||||
} catch (e: BitcoinException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
if (it.isMethod(ElectrumRequest.METHOD_SendTransaction)) {
|
||||
try {
|
||||
var hashTX = it.resultString
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue