aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-06 13:43:56 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-06 13:43:56 +0800
commitb2f6ae9ace496d2896e3d6db0fbc10431115181f (patch)
tree0658929c408d54fe9bccc3afad837ed2392b0a98
parenta915dfdeaa51c80c599b15f4e1ec14c90ac00fbf (diff)
parent3abceac55d16e41b37116a8dda565644ed0a9f52 (diff)
downloadtangerine-wallet-browser-b2f6ae9ace496d2896e3d6db0fbc10431115181f.tar.gz
tangerine-wallet-browser-b2f6ae9ace496d2896e3d6db0fbc10431115181f.tar.zst
tangerine-wallet-browser-b2f6ae9ace496d2896e3d6db0fbc10431115181f.zip
Merge branch 'FailLowBalance' into FailingTestForFailingLowBalanceTx
-rw-r--r--app/scripts/controllers/transactions.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 52251d66e..3f5834756 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -428,10 +428,28 @@ module.exports = class TransactionController extends EventEmitter {
const gtBalance = Number.parseInt(txMeta.txParams.value) > Number.parseInt(balance)
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
- // if the value of the transaction is greater then the balance
- // or the nonce of the transaction is lower then the accounts nonce
- // dont resubmit the tx
- if (gtBalance || txNonce < nonce) return cb()
+ // if the value of the transaction is greater then the balance, fail.
+ if (gtBalance) {
+ txMeta.err = {
+ isWarning: true,
+ message: 'Insufficient balance.',
+ }
+ this.updateTx(txMeta)
+ cb()
+ return log.error(txMeta.err.message)
+ }
+
+ // if the nonce of the transaction is lower then the accounts nonce, fail.
+ if (txNonce < nonce) {
+ txMeta.err = {
+ isWarning: true,
+ message: 'Invalid nonce.',
+ }
+ this.updateTx(txMeta)
+ cb()
+ return log.error(txMeta.err.message)
+ }
+
// Only auto-submit already-signed txs:
if (!('rawTx' in txMeta)) return cb()