diff --git a/bench/index.js b/bench/index.js index 35dbd66..1bf5a81 100644 --- a/bench/index.js +++ b/bench/index.js @@ -99,7 +99,7 @@ options.forEach(options => { break; case 'xpub': - console.log(`Derivation Path: ${data.derivationPath}`); + console.log(`Derivation Index: ${data.index}`); console.log(`xpub: ${data.xpub}`); break; diff --git a/src/key-formats/xpub.js b/src/key-formats/xpub.js index 06dca39..20bb157 100644 --- a/src/key-formats/xpub.js +++ b/src/key-formats/xpub.js @@ -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}; diff --git a/test/vanity-addresses.js b/test/vanity-addresses.js index d939ab9..e941900 100644 --- a/test/vanity-addresses.js +++ b/test/vanity-addresses.js @@ -97,7 +97,7 @@ testCases.forEach(options => { case 'xpub': { const node = bitcoin.bip32.fromBase58(keyData.xpub); - key = node.derivePath(keyData.derivationPath); + key = node.derive(keyData.index); break; }