Updated on 2026-08-14

This commit is contained in:
Tangem 2018-09-05 13:10:40 +03:00
parent b1134eb19e
commit 198457327c
8 changed files with 31 additions and 3 deletions

View file

@ -125,6 +125,9 @@ public class SignPaymentTask extends Thread {
} catch (CardProtocol.TangemException_InvalidPIN e) {
e.printStackTrace();
protocol.setError(e);
} catch (CardProtocol.TangemException_WrongAmount e) {
e.printStackTrace();
protocol.setError(e);
} catch (Exception e) {
e.printStackTrace();
protocol.setError(e);

View file

@ -137,6 +137,12 @@ public class CardProtocol {
}
}
public static class TangemException_WrongAmount extends TangemException {
public TangemException_WrongAmount(String message) {
super(message);
}
}
public byte[] GetUID() {
if (mIsoDep == null || mIsoDep.getTag() == null) return null;
return mIsoDep.getTag().getId();

View file

@ -341,7 +341,7 @@ public class BtcCashEngine extends CoinEngine {
}
if (amount + fees > fullAmount) {
throw new Exception(String.format("Balance (%d) < amount (%d) + (%d)", fullAmount, change, amount));
throw new CardProtocol.TangemException_WrongAmount(String.format("Balance (%d) < amount (%d) + (%d)", fullAmount, change, amount));
}
byte[][] dataForSign = new byte[unspentOutputs.size()][];

View file

@ -498,7 +498,7 @@ public class BtcEngine extends CoinEngine {
}
if (amount + fees > fullAmount) {
throw new Exception(String.format("Balance (%d) < amount (%d) + (%d)", fullAmount, change, amount));
throw new CardProtocol.TangemException_WrongAmount(String.format("Balance (%d) < amount (%d) + (%d)", fullAmount, change, amount));
}
byte[][] dataForSign = new byte[unspentOutputs.size()][];

View file

@ -50,6 +50,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
var minFee: String? = null
var maxFee: String? = null
var normalFee: String? = null
var incFee: Boolean = true
var minFeeInInternalUnits: Long? = 0L
private var requestPIN2Count = 0
var nodeCheck = false
@ -81,7 +82,8 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
} else
tvBalance.text = engine!!.getBalanceWithAlter(card)
if (intent.getBooleanExtra("IncFee", true)) {
incFee = intent.getBooleanExtra("IncFee", true);
if (incFee) {
tvIncFee!!.setText(R.string.including_fee)
} else {
tvIncFee!!.setText(R.string.not_including_fee)
@ -211,6 +213,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
intent.putExtra("UID", card!!.uid)
intent.putExtra("Card", card!!.asBundle)
intent.putExtra("IncFee", incFee)
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2)
}
@ -272,6 +275,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
intent.putExtra("UID", card!!.uid)
intent.putExtra("Card", card!!.asBundle)
intent.putExtra("IncFee", incFee)
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2)
return
}
@ -285,6 +289,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
intent.putExtra("Wallet", etWallet!!.text.toString())
intent.putExtra(SignPaymentActivity.EXTRA_AMOUNT, etAmount!!.text.toString())
intent.putExtra("Fee", etFee!!.text.toString())
intent.putExtra("IncFee", incFee)
startActivityForResult(intent, REQUEST_CODE_SIGN_PAYMENT)
} else
Toast.makeText(baseContext, R.string.pin_2_is_required_to_sign_the_payment, Toast.LENGTH_LONG).show()

View file

@ -179,6 +179,18 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
}
}, 500)
} else {
if (cardProtocol.error is CardProtocol.TangemException_WrongAmount) {
try {
val intent = Intent()
intent.putExtra("message", getString(R.string.cannot_sign_transaction_wrong_amount))
intent.putExtra("UID", cardProtocol.card.uid)
intent.putExtra("Card", cardProtocol.card.asBundle)
setResult(Activity.RESULT_CANCELED, intent)
finish()
} catch (e: Exception) {
e.printStackTrace()
}
}
progressBar!!.post {
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
if (!NoExtendedLengthSupportDialog.allReadyShowed) {