diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-03-14 06:13:05 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-03-14 06:13:05 +0800 |
commit | d195cfab50b42d26f3cf9436845838e075e959de (patch) | |
tree | c83aff86d679819e47d57952219cfc9ae506c5c0 /app | |
parent | 303801d2768a264a27a51916e5debf778739ee0c (diff) | |
download | tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.tar tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.tar.gz tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.tar.bz2 tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.tar.lz tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.tar.xz tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.tar.zst tangerine-wallet-browser-d195cfab50b42d26f3cf9436845838e075e959de.zip |
transactions - insure if a to field in tx params has a truthy valu that it is a valid addres and if it is falsy that it is not null to fix issue #3509
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/tx-gas-utils.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js index 6f6ff7852..e61db3332 100644 --- a/app/scripts/lib/tx-gas-utils.js +++ b/app/scripts/lib/tx-gas-utils.js @@ -4,7 +4,7 @@ const { BnMultiplyByFraction, bnToHex, } = require('./util') -const addHexPrefix = require('ethereumjs-util').addHexPrefix +const {addHexPrefix, isValidAddress} = require('ethereumjs-util') const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send. /* @@ -101,6 +101,12 @@ module.exports = class TxGasUtil { async validateTxParams (txParams) { this.validateRecipient(txParams) + if ('to' in txParams) { + if ( txParams.to === null ) delete txParams.to + else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) { + throw new Error(`Invalid transaction value of ${txParams.to} not a valid to address.`) + } + } if ('value' in txParams) { const value = txParams.value.toString() if (value.includes('-')) { |