getSpecialEthAddress static method

List<SpecialAccount> getSpecialEthAddress({
  1. String regex = r'0x0.*$',
  2. int num = 1,
})

Implementation

static List<SpecialAccount> getSpecialEthAddress(
    {String regex = r'0x0.*$', int num = 1}) {
  final List<SpecialAccount> specialAccounts = [];
  int i = 0;
  while (true) {
    final mnemonic = bip39.generateMnemonic();
    final bip44Path = "m/44'/60'/0'/0/0";
    final Uint8List customPrivateKey =
        HDWallet.bip32DerivePath(mnemonic, bip44Path);
    final Uint8List compressPublicKey = EcdaSignature.privateKeyToPublicKey(
        customPrivateKey,
        compress: false);
    final Uint8List addressBytes = getKeccakDigest(compressPublicKey);
    final String address = addressBytes.sublist(12).toHex();

    if (RegExp(regex).hasMatch(address)) {
      specialAccounts
          .add(new SpecialAccount(mnemonic: mnemonic, address: address));
    }
    if (specialAccounts.length >= num) {
      break;
    }
    i++;
  }
  print(i);
  return specialAccounts;
}