aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-08-09 12:05:59 +0800
committerkumavis <aaron@kumavis.me>2017-08-09 12:05:59 +0800
commit5418813ed146630cf2a84da2d9537955771e4d62 (patch)
treede540e2c0cd367a71b08cae413051ea6c756e947 /app
parentd40bd9a726b7bef900d36ed195e38e8537cc791d (diff)
downloadtangerine-wallet-browser-5418813ed146630cf2a84da2d9537955771e4d62.tar.gz
tangerine-wallet-browser-5418813ed146630cf2a84da2d9537955771e4d62.tar.zst
tangerine-wallet-browser-5418813ed146630cf2a84da2d9537955771e4d62.zip
util - sufficientBalance - validate input
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/util.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js
index 70390e95c..6dee9edf0 100644
--- a/app/scripts/lib/util.js
+++ b/app/scripts/lib/util.js
@@ -1,5 +1,6 @@
const ethUtil = require('ethereumjs-util')
-const BN = ethUtil.BN
+const assert = require('assert')
+const BN = require('bn.js')
module.exports = {
getStack,
@@ -15,6 +16,10 @@ function getStack () {
}
function sufficientBalance (txParams, hexBalance) {
+ // validate hexBalance is a hex string
+ assert.equal(typeof hexBalance, 'string', 'sufficientBalance - hexBalance is not a hex string')
+ assert.equal(hexBalance.slice(0, 2), '0x', 'sufficientBalance - hexBalance is not a hex string')
+
const balance = hexToBn(hexBalance)
const value = hexToBn(txParams.value)
const gasLimit = hexToBn(txParams.gas)