From 27cae64257fad0f20f3537690b44e1be994b1c2a Mon Sep 17 00:00:00 2001 From: Greg Magarshak Date: Mon, 28 Nov 2022 16:15:18 -0500 Subject: [PATCH] Added support for -j option for suffixes --- index.js | 6 ++++++ libs/VanityEth.js | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 907686f..6b61d2d 100755 --- a/index.js +++ b/index.js @@ -25,6 +25,9 @@ const argv = Yargs(process.argv.slice(2)) .alias("i", "input") .string("i") .describe("i", "input hex string") + .alias("j", "input2") + .string("j") + .describe("j", "input hex string") .alias("c", "checksum") .boolean("c") .describe("c", "check against the checksum address") @@ -43,6 +46,7 @@ const argv = Yargs(process.argv.slice(2)) if (cluster.isMaster) { const args = { input: argv.input ? argv.input : "", + input2: argv.input2 ? argv.input2 : "", isChecksum: argv.checksum ? true : false, numWallets: argv.count ? argv.count : 1, isContract: argv.contract ? true : false, @@ -73,6 +77,7 @@ if (cluster.isMaster) { for (let i = 0; i < numCPUs; i++) { const worker_env = { input: args.input, + input2: args.input2, isChecksum: args.isChecksum, isContract: args.isContract, }; @@ -103,6 +108,7 @@ if (cluster.isMaster) { process.send({ account: VanityEth.getVanityWallet( worker_env.input, + worker_env.input2, worker_env.isChecksum == "true", worker_env.isContract == "true", function () { diff --git a/libs/VanityEth.js b/libs/VanityEth.js index da142ef..36e9b9c 100644 --- a/libs/VanityEth.js +++ b/libs/VanityEth.js @@ -14,7 +14,7 @@ var isValidHex = function (hex) { var re = /^[0-9A-F]+$/g; return re.test(hex); }; -var isValidVanityWallet = function (wallet, input, isChecksum, isContract) { +var isValidVanityWallet = function (wallet, input, input2, isChecksum, isContract) { var _add = wallet.address; if (isContract) { var _contractAdd = getDeterministicContractAddress(_add); @@ -22,13 +22,16 @@ var isValidVanityWallet = function (wallet, input, isChecksum, isContract) { ? ethUtils.toChecksumAddress(_contractAdd) : _contractAdd; wallet.contract = _contractAdd; - return _contractAdd.substr(2, input.length) == input; + return _contractAdd.substr(2, input.length) == input + && (!input2 || _contractAdd.substr(-input2.length) == input2); } _add = isChecksum ? ethUtils.toChecksumAddress(_add) : _add; - return _add.substr(2, input.length) == input; + return _add.substr(2, input.length) == input + && (!input2 || _add.substr(-input2.length) == input2); }; var getVanityWallet = function ( input = "", + input2 = "", isChecksum = false, isContract = false, counter = function () {} @@ -36,7 +39,7 @@ var getVanityWallet = function ( if (!isValidHex(input)) throw new Error(ERRORS.invalidHex); input = isChecksum ? input : input.toLowerCase(); var _wallet = getRandomWallet(); - while (!isValidVanityWallet(_wallet, input, isChecksum, isContract)) { + while (!isValidVanityWallet(_wallet, input, input2, isChecksum, isContract)) { counter(); _wallet = getRandomWallet(isChecksum); }