diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-03-14 06:43:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-14 06:43:37 +0800 |
commit | dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb (patch) | |
tree | 3374055e365337973807afd70936afcad070a095 | |
parent | 28a41c203fdb920ed6af3b9484210c4ad0f6093a (diff) | |
parent | b7a24840f2aa358a174d134d7ed30dc3ff2fc4be (diff) | |
download | tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.tar tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.tar.gz tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.tar.bz2 tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.tar.lz tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.tar.xz tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.tar.zst tangerine-wallet-browser-dc5fbf5eb28b3221357197d7fe33ecb2f8a1e6fb.zip |
Merge branch 'master' into i3076-UseStorageLocalInstead
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | app/scripts/lib/tx-gas-utils.js | 6 | ||||
-rw-r--r-- | old-ui/app/keychains/hd/restore-vault.js | 13 | ||||
-rw-r--r-- | ui/app/keychains/hd/restore-vault.js | 13 |
4 files changed, 32 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b4a4cec..e7d4a09fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## Current Master - Add ability for internationalization. +- Will now throw an error if the `to` field in txParams is not valid. +- Will strip null values from the `to` field. - Fix flashing to Log in screen after logging in or restoring from seed phrase. - Increase tap areas for menu buttons on mobile - Change all fonts in new-ui onboarding to Roboto, size 400 diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js index 6f6ff7852..0fa9dd8d4 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. /* @@ -113,12 +113,14 @@ module.exports = class TxGasUtil { } } validateRecipient (txParams) { - if (txParams.to === '0x') { + if (txParams.to === '0x' || txParams.to === null ) { if (txParams.data) { delete txParams.to } else { throw new Error('Invalid recipient address') } + } else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) { + throw new Error('Invalid recipient address') } return txParams } diff --git a/old-ui/app/keychains/hd/restore-vault.js b/old-ui/app/keychains/hd/restore-vault.js index 222172dfd..d334d8e5f 100644 --- a/old-ui/app/keychains/hd/restore-vault.js +++ b/old-ui/app/keychains/hd/restore-vault.js @@ -140,6 +140,19 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () { // check seed var seedBox = document.querySelector('textarea.twelve-word-phrase') var seed = seedBox.value.trim() + + // true if the string has more than a space between words. + if (seed.split(' ').length > 1) { + this.warning = 'there can only be a space between words' + this.props.dispatch(actions.displayWarning(this.warning)) + return + } + // true if seed contains a character that is not between a-z or a space + if (!seed.match(/^[a-z ]+$/)) { + this.warning = 'seed words only have lowercase characters' + this.props.dispatch(actions.displayWarning(this.warning)) + return + } if (seed.split(' ').length !== 12) { this.warning = 'seed phrases are 12 words long' this.props.dispatch(actions.displayWarning(this.warning)) diff --git a/ui/app/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js index d1761f17d..685094854 100644 --- a/ui/app/keychains/hd/restore-vault.js +++ b/ui/app/keychains/hd/restore-vault.js @@ -144,6 +144,19 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () { // check seed var seedBox = document.querySelector('textarea.twelve-word-phrase') var seed = seedBox.value.trim() + + // true if the string has more than a space between words. + if (seed.split(' ').length > 1) { + this.warning = 'there can only a space between words' + this.props.dispatch(actions.displayWarning(this.warning)) + return + } + // true if seed contains a character that is not between a-z or a space + if (!seed.match(/^[a-z ]+$/)) { + this.warning = 'seed words only have lowercase characters' + this.props.dispatch(actions.displayWarning(this.warning)) + return + } if (seed.split(' ').length !== 12) { this.warning = 'seed phrases are 12 words long' this.props.dispatch(actions.displayWarning(this.warning)) |