Skip to content

Commit

Permalink
Merge pull request #887 from Taconut/feature-nophishing
Browse files Browse the repository at this point in the history
Blocked people from sending to addresses listed in CityOfZion/phishing
  • Loading branch information
mhuggins authored Mar 24, 2018
2 parents 54ce5ab + f52e582 commit 23575b3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
32 changes: 19 additions & 13 deletions app/components/Modals/SendModal/SendModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AddRecipientDisplay from './AddRecipientDisplay'
import ConfirmDisplay from './ConfirmDisplay'
import withAddressCheck from './withAddressCheck'

import { validateTransactionBeforeSending, getTokenBalancesMap } from '../../../core/wallet'
import { validateTransactionBeforeSending, getTokenBalancesMap, isInBlacklist } from '../../../core/wallet'
import { ASSETS } from '../../../core/constants'
import { toBigNumber } from '../../../core/math'

Expand Down Expand Up @@ -110,19 +110,25 @@ export default class SendModal extends Component<Props, State> {
handleConfirmAddRecipient = (entry: SendEntryType) => {
const { showErrorNotification } = this.props
const { balances } = this.state
const error = validateTransactionBeforeSending(balances[entry.symbol], entry)

if (error) {
showErrorNotification({ message: error })
} else {
const newBalance = toBigNumber(balances[entry.symbol]).minus(entry.amount).toString()

this.setState({
entries: [...this.state.entries, entry],
balances: { ...balances, [entry.symbol]: newBalance },
display: DISPLAY_MODES.CONFIRM
})
}
isInBlacklist(entry.address).then(inBlacklist => {
if (inBlacklist) {
showErrorNotification({ message: 'You have attempted enter a phishing address.' })
} else {
const error = validateTransactionBeforeSending(balances[entry.symbol], entry)
if (error) {
showErrorNotification({ message: error })
} else {
const newBalance = toBigNumber(balances[entry.symbol]).minus(entry.amount).toString()

this.setState({
entries: [...this.state.entries, entry],
balances: { ...balances, [entry.symbol]: newBalance },
display: DISPLAY_MODES.CONFIRM
})
}
}
})
}

handleCancelAddRecipient = () => {
Expand Down
10 changes: 10 additions & 0 deletions app/core/wallet.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
// @flow
import { wallet } from 'neon-js'
import { map, extend } from 'lodash'
import axios from 'axios'

import { ASSETS } from './constants'
import { toBigNumber } from './math'

const MIN_PASSPHRASE_LEN = 4

let addressBlacklist: Array<string> | null = null
export const isInBlacklist = async (address: string): Promise<boolean> => {
if (addressBlacklist === null) {
const { data } = await axios.get('https://raw.githubusercontent.com/CityOfZion/phishing/master/blockedAddresses.json')
addressBlacklist = data
}
return addressBlacklist.includes(address)
}

export const validatePassphraseLength = (passphrase: string): boolean =>
passphrase.length >= MIN_PASSPHRASE_LEN

Expand Down

0 comments on commit 23575b3

Please sign in to comment.