aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
blob: c52e588631c06868fdbdb3dfd8bdea114b603840 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const KeyringController = require('eth-keyring-controller')

/** @module*/
module.exports = {
  checkAccount,
}

/**
  @param networkId {number}
  @param account {string}
  @returns {array}
*/
async function checkAccount (networkId, account) {

  // mainnet's network id === 1
  if (networkId !== 1) {
    return
  }

  const damnedMnemonic = 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
  const keyringController = new KeyringController({})
  const Keyring = keyringController.getKeyringClassForType('HD Key Tree')
  const opts = {
    mnemonic: damnedMnemonic,
    numberOfAccounts: 10,
  }

  const accountToCheck = account.toLowerCase()
  const keyring = new Keyring(opts)
  const damnedAccounts = await keyring.getAccounts()
  for (let i = 0; i < damnedAccounts.length; i++) {
    if (damnedAccounts[i].toLowerCase() === accountToCheck) {
      throw new Error('Recipient is a public account')
    }
  }
}