Fail pending txs with low balance or invalid nonce

feature/default_network_editable
Dan Finlay 8 years ago
parent 8aab5d965b
commit 3abceac55d
  1. 26
      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) const gtBalance = Number.parseInt(txMeta.txParams.value) > Number.parseInt(balance)
if (!('retryCount' in txMeta)) txMeta.retryCount = 0 if (!('retryCount' in txMeta)) txMeta.retryCount = 0
// if the value of the transaction is greater then the balance // if the value of the transaction is greater then the balance, fail.
// or the nonce of the transaction is lower then the accounts nonce if (gtBalance) {
// dont resubmit the tx txMeta.err = {
if (gtBalance || txNonce < nonce) return cb() 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: // Only auto-submit already-signed txs:
if (!('rawTx' in txMeta)) return cb() if (!('rawTx' in txMeta)) return cb()

Loading…
Cancel
Save