Guest User

Untitled

a guest
Mar 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // You must have node and npm downloaded on your computer
  2.  
  3. // Download bitcoinjs library
  4. npm install bitcoinjs-lib
  5.  
  6. // Require bitcoinjs-lib
  7. var bitcoin = require("bitcoinjs-lib");
  8.  
  9. // Make variable for keyPair
  10. var keyPair = bitcoin.ECPair.makeRandom();
  11.  
  12. // Test by logging address to console and save to variable // A valid bitcoin address should be returned
  13. console.log(keyPair.getAddress());
  14. var address = keyPair.getAddress();
  15.  
  16. // Console Log Wallet Import Format / Private Key and save to variable (WIF)
  17. console.log(keyPair.toWIF());
  18. var pkey = keyPair.toWIF();
  19.  
  20. // Create a custom bitcoin address
  21. var bitcoin = require("bitcoinjs-lib");
  22. var hit = 0; // When it hits the correct custom address
  23. var tryN = 0; // Number of tries
  24. while(hit < 1) // Test addresses
  25. {
  26. let keyPair = bitcoin.ECPair.makeRandom();
  27. let address = keyPair.getAddress();
  28. let pkey = keyPair.toWIF();
  29.  
  30. let custom = address.substring(0,3); // First 3 characters will be custom
  31. console.log(tryN + " " + custom);
  32. if(custom === "1Di" || custom === "1D1"){
  33. console.log(address + " " + pkey);
  34. hit = 2 // So that the while loop stops
  35. }
  36. tryN++;
  37. }
Add Comment
Please, Sign In to add comment