Skip to content

Instantly share code, notes, and snippets.

@dmdque
Created August 1, 2020 08:36
Show Gist options
  • Select an option

  • Save dmdque/14094c15031cd287b46903fcfcc3acf8 to your computer and use it in GitHub Desktop.

Select an option

Save dmdque/14094c15031cd287b46903fcfcc3acf8 to your computer and use it in GitHub Desktop.
const {ethers} = require('ethers')
let node = ethers.utils.HDNode.fromExtendedKey('<xpub...>')
// looks like it already uses "m/44'/60'/0'"
// "account/chain/address"
console.log('node', node)
let found = false;
for (let account = 0; account < 10; account++) {
let address = node.derivePath(`${account}`).address
if (address === '0x4ffE84AE0661A97640ee451a9eDf0c5ecF3a56c0') {
found = true
console.log('#FOUND!')
}
for (let i = 0; i < 10; i++) {
address = node.derivePath(`${account}/${i}`).address
if (address === '0x4ffE84AE0661A97640ee451a9eDf0c5ecF3a56c0') {
found = true
console.log('#FOUND!')
}
for (let j = 0; j < 10; j++) {
address = node.derivePath(`${account}/${i}/${j}`).address
if (address === '0x4ffE84AE0661A97640ee451a9eDf0c5ecF3a56c0') {
found = true
console.log('#FOUND!')
}
}
}
}
if (found) {
console.log('found it')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment