mirror of https://github.com/lukechilds/vainjs.git
Luke Childs
6 years ago
2 changed files with 41 additions and 3 deletions
@ -1,3 +1,39 @@ |
|||||
const vanity = () => {}; |
const bitcoin = require('bitcoinjs-lib'); |
||||
|
|
||||
module.exports = vanity; |
class Vain { |
||||
|
constructor({prefix}) { |
||||
|
this.prefix = `1${prefix}`; |
||||
|
} |
||||
|
|
||||
|
start() { |
||||
|
const startTime = Date.now(); |
||||
|
|
||||
|
let found; |
||||
|
let attempts = 0; |
||||
|
let keyPair; |
||||
|
let address; |
||||
|
|
||||
|
while (!found) { |
||||
|
attempts++; |
||||
|
keyPair = bitcoin.ECPair.makeRandom(); |
||||
|
({address} = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey})); |
||||
|
|
||||
|
if (address.startsWith(this.prefix)) { |
||||
|
found = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const endTime = Date.now(); |
||||
|
const duration = endTime - startTime; |
||||
|
const trysPerSecond = Math.floor(attempts / (duration / 1000)); |
||||
|
|
||||
|
return { |
||||
|
duration, |
||||
|
trysPerSecond, |
||||
|
address, |
||||
|
wif: keyPair.toWIF() |
||||
|
}; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
module.exports = Vain; |
||||
|
Loading…
Reference in new issue