Updated on 2026-08-14
This commit is contained in:
parent
7a94fb82ee
commit
d7c4519c2c
5 changed files with 85 additions and 83 deletions
|
|
@ -50,9 +50,15 @@ public class ServerApiHelperElectrum {
|
|||
Observable<ElectrumRequest> checkBalanceObserver = Observable.just(electrumRequest)
|
||||
.doOnNext(electrumRequest1 -> doElectrumRequest(card, electrumRequest))
|
||||
.flatMap(electrumRequest1 -> {
|
||||
if (electrumRequest1.answerData == null)
|
||||
|
||||
|
||||
// if (electrumRequest1 throws NullPointerException)
|
||||
|
||||
|
||||
if (electrumRequest1.answerData == null) {
|
||||
Log.e(TAG, "NullPointerException " + electrumRequest.getMethod());
|
||||
return Observable.error(new NullPointerException());
|
||||
else
|
||||
} else
|
||||
return Observable.just(electrumRequest1);
|
||||
})
|
||||
.retryWhen(errors -> errors
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import java.security.NoSuchProviderException;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.tangem.util.FormatUtil.GetDecimalFormat;
|
||||
|
|
@ -202,7 +201,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
Double balance = Double.NaN;
|
||||
try {
|
||||
Long val = mCard.getBalance();
|
||||
balance = mCard.AmountFromInternalUnits(val);
|
||||
balance = mCard.amountFromInternalUnits(val);
|
||||
} catch (Exception ex) {
|
||||
mCard.setRate(0);
|
||||
}
|
||||
|
|
@ -212,7 +211,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
|
||||
public String getBalance(TangemCard mCard) {
|
||||
if (mCard.hasBalanceInfo()) {
|
||||
Double balance = mCard.AmountFromInternalUnits(mCard.getBalance());
|
||||
Double balance = mCard.amountFromInternalUnits(mCard.getBalance());
|
||||
return mCard.getAmountDescription(balance);
|
||||
} else {
|
||||
return "";
|
||||
|
|
@ -274,7 +273,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
public String convertByteArrayToAmount(TangemCard mCard, byte[] bytes) throws Exception {
|
||||
byte[] reversed = new byte[bytes.length];
|
||||
for (int i = 0; i < bytes.length; i++) reversed[i] = bytes[bytes.length - i - 1];
|
||||
return FormatUtil.DoubleToString(mCard.AmountFromInternalUnits(Util.byteArrayToLong(reversed)));
|
||||
return FormatUtil.DoubleToString(mCard.amountFromInternalUnits(Util.byteArrayToLong(reversed)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,10 +20,8 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.security.NoSuchProviderException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.tangem.util.FormatUtil.stringToBigDecimal;
|
||||
|
||||
|
|
@ -70,23 +68,23 @@ public class BtcEngine extends CoinEngine {
|
|||
|
||||
static int serviceIndex = 0;
|
||||
|
||||
public String getNode(TangemCard mCard) {
|
||||
switch (mCard.getBlockchain()) {
|
||||
public String getNode(TangemCard card) {
|
||||
switch (card.getBlockchain()) {
|
||||
case Bitcoin:
|
||||
return getBitcoinServiceHosts()[serviceIndex]; //
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getNodePort(TangemCard mCard) {
|
||||
switch (mCard.getBlockchain()) {
|
||||
public int getNodePort(TangemCard card) {
|
||||
switch (card.getBlockchain()) {
|
||||
case Bitcoin:
|
||||
return getBitcoinServicePorts()[serviceIndex];//8080;
|
||||
}
|
||||
return 8080;
|
||||
}
|
||||
|
||||
public void switchNode(TangemCard mCard) {
|
||||
public void switchNode(TangemCard card) {
|
||||
serviceIndex++;
|
||||
if (serviceIndex > getBitcoinServiceHosts().length - 1) serviceIndex = 0;
|
||||
}
|
||||
|
|
@ -99,16 +97,16 @@ public class BtcEngine extends CoinEngine {
|
|||
return card.getBalanceUnconfirmed() != 0;
|
||||
}
|
||||
|
||||
public String getBalanceWithAlter(TangemCard mCard) {
|
||||
return getBalance(mCard);
|
||||
public String getBalanceWithAlter(TangemCard card) {
|
||||
return getBalance(card);
|
||||
}
|
||||
|
||||
public boolean isBalanceAlterNotZero(TangemCard card) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Long getBalanceLong(TangemCard mCard) {
|
||||
return mCard.getBalance();
|
||||
public Long getBalanceLong(TangemCard card) {
|
||||
return card.getBalance();
|
||||
}
|
||||
|
||||
public boolean isBalanceNotZero(TangemCard card) {
|
||||
|
|
@ -134,8 +132,8 @@ public class BtcEngine extends CoinEngine {
|
|||
return "BTC";
|
||||
}
|
||||
|
||||
public boolean checkUnspentTransaction(TangemCard mCard) {
|
||||
return mCard.getUnspentTransactions().size() != 0;
|
||||
public boolean checkUnspentTransaction(TangemCard card) {
|
||||
return card.getUnspentTransactions().size() != 0;
|
||||
}
|
||||
|
||||
public String getFeeCurrency() {
|
||||
|
|
@ -201,20 +199,20 @@ public class BtcEngine extends CoinEngine {
|
|||
return true;
|
||||
}
|
||||
|
||||
public Uri getShareWalletUriExplorer(TangemCard mCard) {
|
||||
return Uri.parse((mCard.getBlockchain() == Blockchain.Bitcoin ? "https://blockchain.info/address/" : "https://testnet.blockchain.info/address/") + mCard.getWallet());
|
||||
public Uri getShareWalletUriExplorer(TangemCard card) {
|
||||
return Uri.parse((card.getBlockchain() == Blockchain.Bitcoin ? "https://blockchain.info/address/" : "https://testnet.blockchain.info/address/") + card.getWallet());
|
||||
}
|
||||
|
||||
public Uri getShareWalletUri(TangemCard mCard) {
|
||||
if (mCard.getDenomination() != null) {
|
||||
return Uri.parse("bitcoin:" + mCard.getWallet() + "?amount=" + BTCUtils.satoshiToBtc(mCard.getDenomination()));
|
||||
public Uri getShareWalletUri(TangemCard card) {
|
||||
if (card.getDenomination() != null) {
|
||||
return Uri.parse("bitcoin:" + card.getWallet() + "?amount=" + BTCUtils.satoshiToBtc(card.getDenomination()));
|
||||
} else {
|
||||
return Uri.parse("bitcoin:" + mCard.getWallet());
|
||||
return Uri.parse("bitcoin:" + card.getWallet());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits, Boolean incfee) {
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits, Boolean isIncludeFee) {
|
||||
Long fee;
|
||||
Long amount;
|
||||
try {
|
||||
|
|
@ -231,44 +229,44 @@ public class BtcEngine extends CoinEngine {
|
|||
if (fee == 0 || amount == 0)
|
||||
return false;
|
||||
|
||||
if (incfee && amount > card.getBalance())
|
||||
if (isIncludeFee && amount > card.getBalance())
|
||||
return false;
|
||||
|
||||
if (!incfee && amount + fee > card.getBalance())
|
||||
if (!isIncludeFee && amount + fee > card.getBalance())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String evaluateFeeEquivalent(TangemCard mCard, String fee) {
|
||||
return getAmountEquivalentDescriptor(mCard, fee);
|
||||
public String evaluateFeeEquivalent(TangemCard card, String fee) {
|
||||
return getAmountEquivalentDescriptor(card, fee);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBalanceEquivalent(TangemCard mCard) {
|
||||
public String getBalanceEquivalent(TangemCard card) {
|
||||
Double balance = Double.NaN;
|
||||
try {
|
||||
Long val = mCard.getBalance();
|
||||
balance = mCard.AmountFromInternalUnits(val);
|
||||
Long val = card.getBalance();
|
||||
balance = card.amountFromInternalUnits(val);
|
||||
} catch (Exception ex) {
|
||||
mCard.setRate(0);
|
||||
card.setRate(0);
|
||||
}
|
||||
|
||||
return mCard.getAmountEquivalentDescription(balance);
|
||||
return card.getAmountEquivalentDescription(balance);
|
||||
}
|
||||
|
||||
public String getBalance(TangemCard mCard) {
|
||||
if (mCard.hasBalanceInfo()) {
|
||||
Double balance = mCard.AmountFromInternalUnits(mCard.getBalance());
|
||||
return mCard.getAmountDescription(balance);
|
||||
public String getBalance(TangemCard card) {
|
||||
if (card.hasBalanceInfo()) {
|
||||
Double balance = card.amountFromInternalUnits(card.getBalance());
|
||||
return card.getAmountDescription(balance);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getBalanceValue(TangemCard mCard) {
|
||||
if (mCard.hasBalanceInfo()) {
|
||||
Double balance = mCard.getBalance() / (mCard.getBlockchain().getMultiplier());
|
||||
public String getBalanceValue(TangemCard card) {
|
||||
if (card.hasBalanceInfo()) {
|
||||
Double balance = card.getBalance() / (card.getBlockchain().getMultiplier());
|
||||
|
||||
String output = FormatUtil.DoubleToString(balance);
|
||||
//String pattern = "#0.000"; // If you like 4 zeros
|
||||
|
|
@ -282,10 +280,9 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
}
|
||||
|
||||
public String calculateAddress(TangemCard mCard, byte[] pkUncompressed) throws NoSuchProviderException, NoSuchAlgorithmException {
|
||||
|
||||
public String calculateAddress(TangemCard card, byte[] pkUncompressed) throws NoSuchProviderException, NoSuchAlgorithmException {
|
||||
byte netSelectionByte;
|
||||
switch (mCard.getBlockchain()) {
|
||||
switch (card.getBlockchain()) {
|
||||
case Bitcoin:
|
||||
netSelectionByte = (byte) 0x00; //0 - MainNet 0x6f - TestNet
|
||||
break;
|
||||
|
|
@ -314,28 +311,27 @@ public class BtcEngine extends CoinEngine {
|
|||
BB.put(hash4[3]);
|
||||
|
||||
return org.bitcoinj.core.Base58.encode(BB.array());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertByteArrayToAmount(TangemCard mCard, byte[] bytes) throws Exception {
|
||||
public String convertByteArrayToAmount(TangemCard card, byte[] bytes) throws Exception {
|
||||
if (bytes == null) return "";
|
||||
byte[] reversed = new byte[bytes.length];
|
||||
for (int i = 0; i < bytes.length; i++) reversed[i] = bytes[bytes.length - i - 1];
|
||||
return FormatUtil.DoubleToString(mCard.AmountFromInternalUnits(Util.byteArrayToLong(reversed)));
|
||||
return FormatUtil.DoubleToString(card.amountFromInternalUnits(Util.byteArrayToLong(reversed)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] convertAmountToByteArray(TangemCard mCard, String amount) throws Exception {
|
||||
byte[] bytes = Util.longToByteArray(mCard.internalUnitsFromString(amount));
|
||||
public byte[] convertAmountToByteArray(TangemCard card, String amount) throws Exception {
|
||||
byte[] bytes = Util.longToByteArray(card.internalUnitsFromString(amount));
|
||||
byte[] reversed = new byte[bytes.length];
|
||||
for (int i = 0; i < bytes.length; i++) reversed[i] = bytes[bytes.length - i - 1];
|
||||
return reversed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAmountDescription(TangemCard mCard, String amount) throws Exception {
|
||||
return mCard.getAmountDescription(Double.parseDouble(amount));
|
||||
public String getAmountDescription(TangemCard card, String amount) throws Exception {
|
||||
return card.getAmountDescription(Double.parseDouble(amount));
|
||||
}
|
||||
|
||||
public static String getAmountEquivalentDescriptionBTC(Double amount, float rate) {
|
||||
|
|
@ -346,19 +342,19 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
}
|
||||
|
||||
public String getAmountEquivalentDescriptor(TangemCard mCard, String value) {
|
||||
return getAmountEquivalentDescriptionBTC(Double.parseDouble(value), mCard.getRate());
|
||||
public String getAmountEquivalentDescriptor(TangemCard card, String value) {
|
||||
return getAmountEquivalentDescriptionBTC(Double.parseDouble(value), card.getRate());
|
||||
}
|
||||
|
||||
public byte[] sign(String feeValue, String amountValue, boolean IncFee, String toValue, TangemCard mCard, CardProtocol protocol) throws Exception {
|
||||
public byte[] sign(String feeValue, String amountValue, boolean IncFee, String toValue, TangemCard card, CardProtocol protocol) throws Exception {
|
||||
|
||||
String myAddress = mCard.getWallet();
|
||||
byte[] pbKey = mCard.getWalletPublicKey();
|
||||
String myAddress = card.getWallet();
|
||||
byte[] pbKey = card.getWalletPublicKey();
|
||||
String outputAddress = toValue;
|
||||
String changeAddress = myAddress;
|
||||
|
||||
// Build script for our address
|
||||
List<TangemCard.UnspentTransaction> rawTxList = mCard.getUnspentTransactions();
|
||||
List<TangemCard.UnspentTransaction> rawTxList = card.getUnspentTransactions();
|
||||
byte[] outputScriptWeAreAbleToSpend = Transaction.Script.buildOutput(myAddress).bytes;
|
||||
|
||||
// Collect unspent
|
||||
|
|
@ -394,7 +390,7 @@ public class BtcEngine extends CoinEngine {
|
|||
unspentOutputs.get(i).bodyDoubleHash = doubleHashData;
|
||||
unspentOutputs.get(i).bodyHash = hashData;
|
||||
|
||||
if (mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw || mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw_Validated_By_Issuer) {
|
||||
if (card.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw || card.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw_Validated_By_Issuer) {
|
||||
dataForSign[i] = newTX;
|
||||
} else {
|
||||
dataForSign[i] = doubleHashData;
|
||||
|
|
@ -402,8 +398,8 @@ public class BtcEngine extends CoinEngine {
|
|||
|
||||
}
|
||||
|
||||
byte[] signFromCard = null;
|
||||
if (mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw || mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw_Validated_By_Issuer) {
|
||||
byte[] signFromCard;
|
||||
if (card.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw || card.getSigningMethod() == TangemCard.SigningMethod.Sign_Raw_Validated_By_Issuer) {
|
||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||
if (dataForSign.length > 10) throw new Exception("To much hashes in one transaction!");
|
||||
for (int i = 0; i < dataForSign.length; i++) {
|
||||
|
|
@ -413,7 +409,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
signFromCard = protocol.run_SignRaw(PINStorage.getPIN2(), bs.toByteArray()).getTLV(TLV.Tag.TAG_Signature).Value;
|
||||
} else {
|
||||
signFromCard = protocol.run_SignHashes(PINStorage.getPIN2(), dataForSign, mCard.getSigningMethod() == TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer, null, mCard.getIssuer()).getTLV(TLV.Tag.TAG_Signature).Value;
|
||||
signFromCard = protocol.run_SignHashes(PINStorage.getPIN2(), dataForSign, card.getSigningMethod() == TangemCard.SigningMethod.Sign_Hash_Validated_By_Issuer, null, card.getIssuer()).getTLV(TLV.Tag.TAG_Signature).Value;
|
||||
// TODO slice signFromCard to hashes.length parts
|
||||
}
|
||||
|
||||
|
|
@ -429,4 +425,5 @@ public class BtcEngine extends CoinEngine {
|
|||
byte[] realTX = BTCUtils.buildTXForSend(outputAddress, changeAddress, unspentOutputs, amount, change);
|
||||
return realTX;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -177,11 +177,11 @@ public class TangemCard {
|
|||
return cardPublicKeyValid;
|
||||
}
|
||||
|
||||
public Double AmountFromInternalUnits(Long internalAmount) {
|
||||
public Double amountFromInternalUnits(Long internalAmount) {
|
||||
return ((double) internalAmount) / getBlockchain().getMultiplier();
|
||||
}
|
||||
|
||||
private Double AmountFromInternalUnits(Integer internalAmount) {
|
||||
public Double amountFromInternalUnits(Integer internalAmount) {
|
||||
return ((double) internalAmount) / getBlockchain().getMultiplier();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
tvWallet.text = card!!.wallet
|
||||
|
||||
// set listeners
|
||||
srl.setOnRefreshListener { refresh() }
|
||||
srl!!.setOnRefreshListener { refresh() }
|
||||
btnLookup.setOnClickListener {
|
||||
val engineClick = CoinEngineFactory.create(card!!.blockchain)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, engineClick.getShareWalletUriExplorer(card))
|
||||
|
|
@ -223,7 +223,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val electrumBodyListener: ServerApiHelperElectrum.ElectrumRequestDataListener = object : ServerApiHelperElectrum.ElectrumRequestDataListener {
|
||||
override fun onElectrumSuccess(electrumRequest: ElectrumRequest?) {
|
||||
requestCounter--
|
||||
if (requestCounter == 0) srl.isRefreshing = false
|
||||
if (requestCounter == 0) srl?.isRefreshing = false
|
||||
|
||||
if (electrumRequest!!.isMethod(ElectrumRequest.METHOD_GetBalance)) {
|
||||
try {
|
||||
|
|
@ -265,7 +265,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val height = jsUnspent.getInt("height")
|
||||
val hash = jsUnspent.getString("tx_hash")
|
||||
if (height != -1) {
|
||||
requestElectrum(card!!, ElectrumRequest.getTransaction(walletAddress, hash))
|
||||
// requestElectrum(card!!, ElectrumRequest.getTransaction(walletAddress, hash))
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
|
|
@ -295,7 +295,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
|
||||
override fun onElectrumFail(method: String?) {
|
||||
srl.isRefreshing = false
|
||||
// srl.isRefreshing = false
|
||||
Log.e(TAG, "FAIL $method")
|
||||
}
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
// request card verify listener
|
||||
serverApiHelper!!.setCardVerifyAndGetInfoListener {
|
||||
requestCounter--
|
||||
if (requestCounter == 0) srl.isRefreshing = false
|
||||
if (requestCounter == 0) srl!!.isRefreshing = false
|
||||
|
||||
val result = it.results!![0]
|
||||
if (result.error != null) {
|
||||
|
|
@ -350,7 +350,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
card!!.rateAlter = rate
|
||||
|
||||
if (requestCounter == 0) {
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
updateViews()
|
||||
}
|
||||
// Log.i(TAG, "setRateInfoData $rate")
|
||||
|
|
@ -406,7 +406,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
card!!.addTokenToBlockchainName()
|
||||
|
||||
requestCounter--
|
||||
if (requestCounter == 0) srl.isRefreshing = false
|
||||
if (requestCounter == 0) srl!!.isRefreshing = false
|
||||
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_BALANCE, "")
|
||||
requestInfura(ServerApiHelper.INFURA_ETH_GET_TRANSACTION_COUNT, "")
|
||||
|
|
@ -465,7 +465,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
requestCounter--
|
||||
if (requestCounter == 0) {
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
updateViews()
|
||||
}
|
||||
}
|
||||
|
|
@ -473,7 +473,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
override fun onInfuraFail(method: String, message: String) {
|
||||
requestCounter--
|
||||
if (requestCounter == 0) {
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
updateViews()
|
||||
}
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiHelperElectrum!!.electrumRequestData(card, electrumRequest)
|
||||
} else {
|
||||
Toast.makeText(activity!!, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -499,7 +499,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiHelper!!.infura(method, 67, card!!.wallet, contract, "")
|
||||
} else {
|
||||
Toast.makeText(activity!!, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -511,7 +511,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
} else {
|
||||
Toast.makeText(activity!!, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
serverApiHelper!!.rateInfoData(cryptoId)
|
||||
} else {
|
||||
Toast.makeText(activity!!, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
srl.isRefreshing = false
|
||||
srl!!.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -681,8 +681,8 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
REQUEST_CODE_SEND_PAYMENT, REQUEST_CODE_RECEIVE_PAYMENT -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
card!!.clearInfo()
|
||||
srl.postDelayed({ this.refresh() }, 5000)
|
||||
srl.isRefreshing = true
|
||||
srl!!.postDelayed({ this.refresh() }, 5000)
|
||||
srl!!.isRefreshing = true
|
||||
updateViews()
|
||||
}
|
||||
|
||||
|
|
@ -802,7 +802,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
val engine = CoinEngineFactory.create(card!!.blockchain)
|
||||
|
||||
if (srl.isRefreshing) {
|
||||
if (srl!!.isRefreshing) {
|
||||
tvBalanceLine1.setTextColor(resources.getColor(R.color.primary))
|
||||
tvBalanceLine1.text = getString(R.string.verifying_in_blockchain)
|
||||
tvBalanceLine2.text = ""
|
||||
|
|
@ -851,7 +851,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
private fun refresh() {
|
||||
// clear all card data and request again
|
||||
srl.isRefreshing = true
|
||||
srl!!.isRefreshing = true
|
||||
card!!.clearInfo()
|
||||
card!!.error = null
|
||||
card!!.message = null
|
||||
|
|
@ -868,7 +868,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
card!!.setIsBalanceEqual(true)
|
||||
|
||||
requestElectrum(card!!, ElectrumRequest.checkBalance(card!!.wallet))
|
||||
requestElectrum(card!!, ElectrumRequest.listUnspent(card!!.wallet))
|
||||
// requestElectrum(card!!, ElectrumRequest.listUnspent(card!!.wallet))
|
||||
requestRateInfo("bitcoin")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue