diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-07-12 03:29:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-12 03:29:20 +0800 |
commit | a1fd9bc6bebcad4421a10ab85f525b9686103549 (patch) | |
tree | 01ac51e1506cd5c7a989cb6e071982e72f1714b4 /app/scripts/lib/tx-utils.js | |
parent | 0eee232e26dec61512e36bedf131ce0f7ce1ddd4 (diff) | |
parent | c7b9e3fb1878cebbab26d5343cc18084a601c6bb (diff) | |
download | tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.tar tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.tar.gz tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.tar.bz2 tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.tar.lz tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.tar.xz tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.tar.zst tangerine-wallet-browser-a1fd9bc6bebcad4421a10ab85f525b9686103549.zip |
Merge pull request #1762 from MetaMask/ImproveRetryLogic
Improve retry logic
Diffstat (limited to 'app/scripts/lib/tx-utils.js')
-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) + } } |