A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js

37 lines
994 B

const KeyringController = require('eth-keyring-controller')
/** @module*/
module.exports = {
checkAccount,
}
/**
* Checks if a specified account on a specified network is blacklisted.
@param networkId {number}
@param account {string}
*/
async function checkAccount (networkId, account) {
const mainnetId = 1
if (networkId !== mainnetId) {
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')
}
}
}