diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-07-06 13:06:39 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-07-06 13:43:31 +0800 |
commit | 3abceac55d16e41b37116a8dda565644ed0a9f52 (patch) | |
tree | 55a9326986d4113ca814c3721fc7e5c39e30dcbf | |
parent | 8aab5d965b2095683baaf35bf1de6450de981800 (diff) | |
download | tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.tar tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.tar.gz tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.tar.bz2 tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.tar.lz tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.tar.xz tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.tar.zst tangerine-wallet-browser-3abceac55d16e41b37116a8dda565644ed0a9f52.zip |
Fail pending txs with low balance or invalid nonce
-rw-r--r-- | app/scripts/controllers/transactions.js | 26 |
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() |