mirror of https://github.com/lukechilds/vainjs.git
Luke Childs
6 years ago
2 changed files with 22 additions and 2 deletions
@ -0,0 +1,19 @@ |
|||
const bitcoin = require('bitcoinjs-lib'); |
|||
|
|||
const generateXpubKey = ({options, attempts}) => { |
|||
const change = 0; |
|||
const index = attempts - 1; |
|||
const derivationPath = `${change}/${index}`; |
|||
|
|||
const node = bitcoin.bip32.fromBase58(options.xpub); |
|||
const {publicKey} = node.derivePath(derivationPath); |
|||
|
|||
const format = () => ({ |
|||
xpub: options.xpub, |
|||
derivationPath |
|||
}); |
|||
|
|||
return {publicKey, format}; |
|||
}; |
|||
|
|||
module.exports = generateXpubKey; |
Loading…
Reference in new issue