|
|
@ -1,16 +1,14 @@ |
|
|
|
const bitcoin = require('bitcoinjs-lib'); |
|
|
|
|
|
|
|
const generateXpubKey = ({attempts, xpub}) => { |
|
|
|
const change = 0; |
|
|
|
const index = attempts - 1; |
|
|
|
const derivationPath = `${change}/${index}`; |
|
|
|
|
|
|
|
const node = bitcoin.bip32.fromBase58(xpub); |
|
|
|
const {publicKey} = node.derivePath(derivationPath); |
|
|
|
const {publicKey} = node.derive(index); |
|
|
|
|
|
|
|
const format = () => ({ |
|
|
|
xpub, |
|
|
|
derivationPath |
|
|
|
index |
|
|
|
}); |
|
|
|
|
|
|
|
return {publicKey, format}; |
|
|
|