Browse Source

Add basic P2PKH address miner

master
Luke Childs 6 years ago
parent
commit
24373876ac
  1. 4
      package.json
  2. 40
      src/index.js

4
package.json

@ -32,5 +32,7 @@
"nyc": "^13.1.0", "nyc": "^13.1.0",
"xo": "^0.23.0" "xo": "^0.23.0"
}, },
"dependencies": {} "dependencies": {
"bitcoinjs-lib": "^5.0.3"
}
} }

40
src/index.js

@ -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…
Cancel
Save