Updated on 2026-08-14
This commit is contained in:
commit
692682e750
8 changed files with 31 additions and 28 deletions
|
|
@ -176,7 +176,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
return Uri.parse("bitcoincash:" + mCard.getWallet());
|
||||
}
|
||||
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits) {
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits, Boolean incfee) {
|
||||
Long fee;
|
||||
Long amount;
|
||||
try {
|
||||
|
|
@ -193,10 +193,10 @@ public class BtcCashEngine extends CoinEngine {
|
|||
if (fee == 0 || amount == 0)
|
||||
return false;
|
||||
|
||||
if (fee > amount)
|
||||
if (incfee && amount > card.getBalance())
|
||||
return false;
|
||||
|
||||
if (fee < minFeeInInternalUnits)
|
||||
if (!incfee && amount + fee > card.getBalance())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits) {
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits, Boolean incfee) {
|
||||
Long fee;
|
||||
Long amount;
|
||||
try {
|
||||
|
|
@ -350,10 +350,10 @@ public class BtcEngine extends CoinEngine {
|
|||
if (fee == 0 || amount == 0)
|
||||
return false;
|
||||
|
||||
if (fee > amount)
|
||||
if (incfee && amount > card.getBalance())
|
||||
return false;
|
||||
|
||||
if (fee < minFeeInInternalUnits)
|
||||
if (!incfee && amount + fee > card.getBalance())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public abstract class CoinEngine {
|
|||
|
||||
public abstract String evaluateFeeEquivalent(TangemCard card, String fee);
|
||||
|
||||
public abstract boolean checkAmountValue(TangemCard card, String amount, String fee, Long minFeeInInternalUnits);
|
||||
public abstract boolean checkAmountValue(TangemCard card, String amount, String fee, Long minFeeInInternalUnits, Boolean incfee);
|
||||
|
||||
public abstract boolean inOutPutVisible();
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public class EthEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
|
||||
public boolean checkAmountValue(TangemCard mCard, String amountValue, String feeValue, Long minFeeInInternalUnits) {
|
||||
public boolean checkAmountValue(TangemCard mCard, String amountValue, String feeValue, Long minFeeInInternalUnits, Boolean incfee) {
|
||||
// Long fee = null;
|
||||
// Long amount = null;
|
||||
// try {
|
||||
|
|
@ -270,9 +270,18 @@ public class EthEngine extends CoinEngine {
|
|||
try {
|
||||
BigDecimal tmpFee = new BigDecimal(feeValue);
|
||||
BigDecimal tmpAmount = new BigDecimal(amountValue);
|
||||
BigDecimal cardBalance = new BigDecimal(mCard.getDecimalBalance());
|
||||
tmpAmount = tmpAmount.multiply(new BigDecimal("1000000000"));
|
||||
if (tmpFee.compareTo(tmpAmount) > 0)
|
||||
cardBalance = cardBalance.divide(new BigDecimal("1000000000"));
|
||||
//if (tmpFee.compareTo(tmpAmount) > 0)
|
||||
// return false;
|
||||
|
||||
if (incfee && tmpAmount.compareTo(cardBalance) > 0 )
|
||||
return false;
|
||||
|
||||
if (!incfee && tmpAmount.add(tmpFee).compareTo(cardBalance) > 0)
|
||||
return false;
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ public class TokenEngine extends CoinEngine {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits) {
|
||||
public boolean checkAmountValue(TangemCard card, String amountValue, String feeValue, Long minFeeInInternalUnits, Boolean incfee) {
|
||||
Long fee;
|
||||
BigDecimal amount;
|
||||
try {
|
||||
|
|
@ -309,17 +309,12 @@ public class TokenEngine extends CoinEngine {
|
|||
if (fee == 0 || amount.compareTo(BigDecimal.ZERO) == 0)
|
||||
return false;
|
||||
|
||||
|
||||
if (fee < minFeeInInternalUnits)
|
||||
return false;
|
||||
|
||||
|
||||
BigDecimal tmpFee = new BigDecimal(feeValue);
|
||||
BigDecimal tmpAmount = amount;
|
||||
tmpAmount = tmpAmount.multiply(new BigDecimal("1000000000"));
|
||||
|
||||
if (tmpFee.compareTo(tmpAmount) > 0)
|
||||
return false;
|
||||
// BigDecimal tmpFee = new BigDecimal(feeValue);
|
||||
// BigDecimal tmpAmount = amount;
|
||||
// tmpAmount = tmpAmount.multiply(new BigDecimal("1000000000"));
|
||||
//
|
||||
// if (tmpFee.compareTo(tmpAmount) > 0)
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -357,7 +352,7 @@ public class TokenEngine extends CoinEngine {
|
|||
//amount = amount.subtract(fee);
|
||||
|
||||
BigInteger nonce = nonceValue;
|
||||
BigInteger gasPrice = fee.divide(BigInteger.valueOf(21000));
|
||||
BigInteger gasPrice = fee.divide(BigInteger.valueOf(60000));
|
||||
BigInteger gasLimit = BigInteger.valueOf(60000);
|
||||
Integer chainId = EthTransaction.ChainEnum.Mainnet.getValue();
|
||||
BigInteger amountZero = BigInteger.ZERO;
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (!engineCoin.checkAmountValue(card, txAmount, txFee, minFeeInInternalUnits)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_eth_for_transaction_fee))
|
||||
if (!engineCoin.checkAmountValue(card, txAmount, txFee, minFeeInInternalUnits, incFee)) {
|
||||
finishActivityWithError(Activity.RESULT_CANCELED, getString(R.string.not_enough_funds_or_incorrect_amount))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
gasPrice = gasPrice.substring(2)
|
||||
var l = BigInteger(gasPrice, 16)
|
||||
|
||||
val m = if (card!!.blockchain == Blockchain.Token) BigInteger.valueOf(55000) else BigInteger.valueOf(21000)
|
||||
val m = if (card!!.blockchain == Blockchain.Token) BigInteger.valueOf(60000) else BigInteger.valueOf(21000)
|
||||
l = l.multiply(m)
|
||||
val minFeeInGwei = card!!.getAmountInGwei(l.toString())
|
||||
val normalFeeInGwei = card!!.getAmountInGwei(l.multiply(BigInteger.valueOf(12)).divide(BigInteger.valueOf(10)).toString())
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
} else if (!engine.isBalanceNotZero(card))
|
||||
showSingleToast(R.string.wallet_empty)
|
||||
else if (!engine.isBalanceAlterNotZero(card))
|
||||
showSingleToast(R.string.not_enough_funds)
|
||||
showSingleToast(R.string.not_enough_funds_or_incorrect_amount)
|
||||
else if (engine.awaitingConfirmation(card))
|
||||
showSingleToast(R.string.please_wait_while_previous)
|
||||
else if (!engine.checkUnspentTransaction(card))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue