Created
June 1, 2018 03:42
-
-
Save losh11/03e01061bcf4e5867570fa6b3e2b7d54 to your computer and use it in GitHub Desktop.
shitty js code which finds your paper-key if you forget 1 of 12 paper-key words. i guess it works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios') | |
const bip32 = require('bip32') | |
const bip39 = require('bip39') | |
const bitcoin = require('bitcoinjs-lib') | |
const fs = require('fs') | |
const readline = require('readline') | |
const phraseFinder = (phrase, callback) => { | |
// take in phrase and split into array | |
// guessed word is ? | |
let splitPhrase = phrase.split(' ') | |
for (let a = 0; a < phrase.length; a++) { | |
if (splitPhrase[a] === '?') { | |
guessOneWord('english.txt', (guessArray) => { | |
for (let b = 0; b < guessArray.length; b++) { | |
splitPhrase[a] = guessArray[b] | |
joinedPhrase = splitPhrase.join(' ') | |
if (bip39.validateMnemonic(joinedPhrase) === true) { | |
callback(joinedPhrase) | |
} | |
} | |
}) | |
} | |
} | |
} | |
const guessOneWord = (wordlist, callback) => { | |
// configure readline to read bip39 wordlist | |
const rl = readline.createInterface({ | |
input: fs.createReadStream(wordlist) | |
}) | |
// iterates through lines in wordlist txt | |
let array = new Array() | |
rl.on('line', (line) => { | |
array.push(line) | |
// array is filled! | |
if (array.length == 2048) { | |
callback(array) | |
} | |
}) | |
} | |
const getAddress = (node, network) => { | |
network = bitcoin.networks.litecoin | |
return bitcoin.address.toBase58Check(bitcoin.crypto.hash160(node.publicKey), network.pubKeyHash) | |
} | |
const searchForValue = (address) => { | |
let url = 'https://insight.litecore.io/api/addr/' + address | |
axios.get(url) | |
.then(res => { | |
if (res.data.totalReceived != 0) { | |
console.log('matched: ', address) | |
} | |
}) | |
} | |
phraseFinder('process again clever large gun april ? since climb brother kick myth', (phrase) => { | |
let path = "m/0'/0/0" | |
let seed = bip39.mnemonicToSeed(phrase) | |
let node = bip32.fromSeed(seed) | |
let child = node.derivePath(path) | |
let xpub = node.toBase58() | |
searchForValue(getAddress(child)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment