Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // You must have node and npm downloaded on your computer
- // Download bitcoinjs library
- npm install bitcoinjs-lib
- // Require bitcoinjs-lib
- var bitcoin = require("bitcoinjs-lib");
- // Make variable for keyPair
- var keyPair = bitcoin.ECPair.makeRandom();
- // Test by logging address to console and save to variable // A valid bitcoin address should be returned
- console.log(keyPair.getAddress());
- var address = keyPair.getAddress();
- // Console Log Wallet Import Format / Private Key and save to variable (WIF)
- console.log(keyPair.toWIF());
- var pkey = keyPair.toWIF();
- // Create a custom bitcoin address
- var bitcoin = require("bitcoinjs-lib");
- var hit = 0; // When it hits the correct custom address
- var tryN = 0; // Number of tries
- while(hit < 1) // Test addresses
- {
- let keyPair = bitcoin.ECPair.makeRandom();
- let address = keyPair.getAddress();
- let pkey = keyPair.toWIF();
- let custom = address.substring(0,3); // First 3 characters will be custom
- console.log(tryN + " " + custom);
- if(custom === "1Di" || custom === "1D1"){
- console.log(address + " " + pkey);
- hit = 2 // So that the while loop stops
- }
- tryN++;
- }
Add Comment
Please, Sign In to add comment