Skip to content

Commit

Permalink
Merge pull request #9 from decentraliser/vanity-types
Browse files Browse the repository at this point in the history
chose vanity types, fixes #4
vanity types explaination, fixes #2
  • Loading branch information
decentraliser authored Mar 21, 2020
2 parents 0a6bca7 + 59e8811 commit 95c9dc6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
50 changes: 46 additions & 4 deletions src/commands/generator/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,74 @@ import prompts from 'prompts'

// internal
import { ExtendedKeysGenerator } from '../../services/ExtendedKeysGenerator'
import { Classifier } from '../../services/Classifier'
import { Classifier, VanityType } from '../../services/Classifier'
import { Results } from '../../services/Results'
import { WordFinder } from '../../services/WordFinder'
import { Match } from '../../model/Match'

import derivationPaths from '../../../assets/paths.json'

const { paths } = derivationPaths

const vanityOptions: VanityType[] = [
'left',
'right',
2,
3,
4,
5,
6,
7,
'free',
]

// @TODO: Network type as option
@command({
description: 'Start the vanity address generator',
})
export default class extends Command {
@metadata
async execute() {
const choices = Object.keys(NetworkType)
console.info('\n\n')
console.info('Vanity type classification: ')
console.info('Left: The world starts at the first or second character of the address')
console.info('COOL: T*COOL*C-QVTCDN-42YROV-WLMAPB-LD55ZS-756IPJ-PB67')
console.info('---')
console.info('Right: The word is in the last characters of an address')
console.info('SYMBOL: TOPDD-QVTCDN-42YROV-WLMAPB-LD55ZS-756I*SY-MBOL*')
console.info('---')
console.info('Chunk number: The first letter of the word matches the first letter of a pretty address chunk')
console.info('AWESOME in chunk 3: TOPDD-TEWSI-*AWESOM-E*EOMEA-LD55ZS-756ISD-MDWE')
console.info('---')
console.info('Free: None of the above')
console.info('VANITY: TALBSJ-E7WK5S-QL5*VAN-ITY*GYG-RX67AZ-V7GZX2-M7TJ')
console.info('\n\n')


const networkTypesChoices = Object.keys(NetworkType)
.filter((key) => Number.isNaN(parseFloat(key)))
.map((word) => ({ title: word, value: word }))

const vanityChoices = vanityOptions.map((choice) => ({ title: choice, value: choice }))

const questions: any = [
{
type: 'select',
name: 'networkType',
message: 'Chose a network type',
choices,
choices: networkTypesChoices,
},
{
type: 'multiselect',
name: 'vanityTypes',
message: 'Chose the vanity types you want',
choices: vanityChoices,
min: 1,
},
]

const response = await prompts(questions)
const chosenVanityTypes = response.vanityTypes

let count = 0

Expand All @@ -73,8 +112,9 @@ export default class extends Command {
return
}

console.info('Looking for:')
console.info(`Start searching for ${response.networkType} addresses containing the words:`)
console.table(wordFinder.wordList)
console.info(`Vanity types: ${chosenVanityTypes}`)

// instantiate extended keys generator
const extendedKeysGenerator = ExtendedKeysGenerator.create()
Expand Down Expand Up @@ -105,6 +145,8 @@ export default class extends Command {
matches.forEach((match: Match) => {
const vanityType = Classifier.getVanityType(match)

if (!chosenVanityTypes.includes(vanityType)) return

console.info('New match!')
console.table({ ...match, vanityType })

Expand Down
2 changes: 1 addition & 1 deletion src/services/Classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ADDRESS_LENGTH = 40
/**
* Representation of a pretty address chunks
*/
export type ChunkNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7
export type ChunkNumber = 2 | 3 | 4 | 5 | 6 | 7
/**
* Classifies the way a word shows in an address
* left: at the left of the address, starting from the first or second letter
Expand Down

0 comments on commit 95c9dc6

Please sign in to comment.