-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcesc-vanity.js
97 lines (86 loc) · 2.69 KB
/
cesc-vanity.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const HdAddGen = require('hdaddressgenerator')
const isSubprocess = typeof process.send !== 'undefined'
const lookFor = process.argv.slice(2).map(f => {
return f.toLowerCase().replace(/[^a-zA-Z0-9]/g, '')
})
if (!isSubprocess) {
console.log('\x1b[36m%s\x1b[0m', 'Cryptoescudo Vanity Wallet Generator')
console.log('\x1b[36m%s\x1b[0m', ' adapted from xrp-vanity-generator by @WietseWind (Twitter) /u/pepperew (Reddit)')
console.log()
}
const run = async (id, match) => {
const re = '^(C)(' + match.join('|') + ')(.+)$|^(C.+)(' + match.join('|') + ')$'
const regexp = new RegExp(re, 'i')
if (match.length > 0) {
if (!isSubprocess) {
console.log('Looking for wallet addresses with keywords at the start/end:')
match.forEach(function (k) {
console.log(' - ', k)
})
console.log(' ')
console.log('For the geeks: testing regular expression: ')
console.log(' ', re)
console.log()
console.log('\x1b[33m%s\x1b[0m', '-- Press Control C to quit --');
console.log()
}
for (let i = 0;;i++) {
let mnemonic = await HdAddGen.generateMnemonic('english',128);
//console.log(mnemonic);
let bip44 = await HdAddGen.withMnemonic(mnemonic.mnemonic,false,"CESC")
let addresses = await bip44.generate(1)
addresses.forEach((address)=>{
const account = {
path: address.path,
address: address.address,
pubKey: address.pubKey,
privKey: address.privKey,
mnemonic: mnemonic.mnemonic
}
const test = regexp.exec(account.address)
//console.log(test)
if (test) {
const matchedAddress = test[1] === undefined
? test[4] + '\x1b[32m' + test[5] + '\x1b[0m'
: test[1] + '\x1b[32m' + test[2] + '\x1b[0m' + test[3]
if (!isSubprocess) {
process.stdout.write("\n")
console.log(` > Match: [ ${matchedAddress} ]`)
console.log(JSON.stringify(account))
} else {
process.send({
match: {
path: address.path,
address: address.address,
pubKey: address.pubKey,
privKey: address.privKey,
mnemonic: mnemonic.mnemonic
},
child: id,
pid: process.pid
})
}
} else {
if (!isSubprocess) {
if (i % 100 === 0) process.stdout.write('.')
if (i % 1000 === 0) process.stdout.write("\r" + i + ' ')
} else {
if (i % 100 === 0) process.send({ counter: 100, child: id, pid: process.pid })
}
}
});
}
} else {
console.log('Please enter one or more keywords after the script to search for.')
console.log('Eg. "node ' + process.argv[1] + ' johndoe mywallet cesc"')
console.log('')
process.exit(0)
}
}
if (!isSubprocess) {
run(null, lookFor)
} else {
process.on('message', msg => {
run(msg.id, msg.lookFor)
})
}