From bb6e41963d42a91ecc34a728b7c0c18d26e6cd9f Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 5 Jun 2017 11:40:20 -0700 Subject: [PATCH] Dissallow transactions to be sent to 0x0000000000000000000000000000000000000000 --- ui/app/components/ens-input.js | 1 + ui/app/components/pending-tx.js | 14 +++++++++++++- ui/app/conf-tx.js | 1 + ui/app/send.js | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index 3e44d83af..11e0fb36d 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -95,6 +95,7 @@ EnsInput.prototype.lookupEnsName = function () { log.info(`ENS attempting to resolve name: ${recipient}`) this.ens.lookup(recipient.trim()) .then((address) => { + if (address === '0x0000000000000000000000000000000000000000') throw new Error('No address has been set for this name.') if (address !== ensResolution) { this.setState({ loadingEns: false, diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index b46f715bc..e8bf32d92 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -44,6 +44,9 @@ PendingTx.prototype.render = function () { const account = props.accounts[address] const balance = account ? account.balance : '0x0' + // recipient check + const isValidAddress = !(txParams.to === '0x0000000000000000000000000000000000000000') + // Gas const gas = txParams.gas const gasBn = hexToBn(gas) @@ -261,6 +264,15 @@ PendingTx.prototype.render = function () { }, 'Transaction Error. Exception thrown in contract code.') : null, + !isValidAddress ? + h('.error', { + style: { + marginLeft: 50, + fontSize: '0.9em', + }, + }, 'Recipient address is invalid sending this transaction will result in a loss of ETH.') + : null, + insufficientBalance ? h('span.error', { style: { @@ -298,7 +310,7 @@ PendingTx.prototype.render = function () { type: 'submit', value: 'ACCEPT', style: { marginLeft: '10px' }, - disabled: insufficientBalance || !this.state.valid, + disabled: insufficientBalance || !this.state.valid || !isValidAddress, }), h('button.cancel.btn-red', { diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js index 008627ce6..4ae81f35f 100644 --- a/ui/app/conf-tx.js +++ b/ui/app/conf-tx.js @@ -48,6 +48,7 @@ ConfirmTxScreen.prototype.render = function () { var txParams = txData.params || {} var isNotification = isPopupOrNotification() === 'notification' + log.info(`rendering a combined ${unconfTxList.length} unconf msg & txs`) if (unconfTxList.length === 0) return h(Loading, { isLoading: true }) diff --git a/ui/app/send.js b/ui/app/send.js index fd6994145..e0896035e 100644 --- a/ui/app/send.js +++ b/ui/app/send.js @@ -262,7 +262,7 @@ SendTransactionScreen.prototype.onSubmit = function () { return this.props.dispatch(actions.displayWarning(message)) } - if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData)) { + if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData) || (recipient === '0x0000000000000000000000000000000000000000')) { message = 'Recipient address is invalid.' return this.props.dispatch(actions.displayWarning(message)) }