Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
shitty js code which finds your paper-key if you forget 1 of 12 paper-key words. i guess it works
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