diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-07-12 03:18:07 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-07-12 03:19:01 +0800 |
commit | c7b9e3fb1878cebbab26d5343cc18084a601c6bb (patch) | |
tree | 1afe10a7c6f4107486ea32ee72323c75dec707a2 /app/scripts/lib | |
parent | d97c6533b87b0a9dd6937c1ca57ec05129ac619b (diff) | |
download | tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.gz tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.bz2 tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.lz tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.xz tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.tar.zst tangerine-wallet-browser-c7b9e3fb1878cebbab26d5343cc18084a601c6bb.zip |
Improve insufficient balance checking in retry loop
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/tx-utils.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js index 149d93102..4e780fcc0 100644 --- a/app/scripts/lib/tx-utils.js +++ b/app/scripts/lib/tx-utils.js @@ -118,6 +118,15 @@ module.exports = class txProviderUtils { } } + sufficientBalance (tx, hexBalance) { + const balance = hexToBn(hexBalance) + const value = hexToBn(tx.value) + const gasLimit = hexToBn(tx.gas) + const gasPrice = hexToBn(tx.gasPrice) + + const maxCost = value.add(gasLimit.mul(gasPrice)) + return balance.gte(maxCost) + } } |