Created
April 10, 2019 23:11
-
-
Save alwaysAn0n/b9da838d62dc0a524d923f1f6c341850 to your computer and use it in GitHub Desktop.
Bitbox Child WIF generation
This file contains 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
var NETWORK = `mainnet` | |
var _ = require('lodash'); | |
var BITBOXSDK = require('bitbox-sdk/lib/bitbox-sdk').default; | |
var BITBOX | |
if (NETWORK === `mainnet`) | |
BITBOX = new BITBOXSDK({ restURL: `https://rest.bitcoin.com/v2/` }) | |
else BITBOX = new BITBOXSDK({ restURL: `https://trest.bitcoin.com/v2/` }) | |
var fs = require('fs') | |
var lang = 'english'; | |
// These objects used for writing walvar information out to a file. | |
var outStr = '' | |
var outObj = {} | |
var mnemonic = '<enter mnemonic>'; | |
BITBOX.Mnemonic.toEntropy(mnemonic) | |
// root seed buffer | |
var rootSeed = BITBOX.Mnemonic.toSeed(mnemonic) | |
// master HDNode | |
var masterHDNode | |
if (NETWORK === `mainnet`) masterHDNode = BITBOX.HDNode.fromSeed(rootSeed) | |
else masterHDNode = BITBOX.HDNode.fromSeed(rootSeed, 'testnet') // Testnet | |
var things = []; | |
var counter = { | |
y: 5 | |
}; | |
var addressWeWant = 'bitcoincash:qpapkex6asqtg3zgft833ea8jndxf6ekxgdyae9am6'; | |
var getChild = function(x, y) { | |
var path = `m/44'/${x}'/0'/0/${y}`; | |
var childNode = masterHDNode.derivePath(path); | |
return { | |
cashAddress: BITBOX.HDNode.toCashAddress(childNode), | |
wifCompressed: BITBOX.HDNode.toWIF(childNode), | |
path: path, | |
y: y | |
} | |
} | |
while (counter.y > -1) { | |
things.push(getChild(145,counter.y)); | |
things.push(getChild(0,counter.y)); | |
counter.y = counter.y-1; | |
console.log('Count:',counter.y); | |
} | |
console.log('We want:', addressWeWant,'\n\n'); | |
var gotIt = _.find(things, {cashAddress: addressWeWant}); | |
if (gotIt) { | |
console.log('Look! We got it:', gotIt); | |
} | |
console.log('\n\nThese are not it but were near it:') | |
console.log(things[gotIt.y+1]) | |
console.log(things[gotIt.y+2]) | |
process.exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment