From a2c93b098338cf032a31e61fae32ee2ca37bd9ec Mon Sep 17 00:00:00 2001 From: Oleg K Date: Tue, 8 Feb 2022 23:13:28 +0200 Subject: [PATCH] Fixed depth for xpub --- hdAddressGenerator.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hdAddressGenerator.js b/hdAddressGenerator.js index d213875..f565898 100644 --- a/hdAddressGenerator.js +++ b/hdAddressGenerator.js @@ -372,8 +372,8 @@ class AddressGenerator { keyPair.pairBuffers = {} keyPair.rawAddress = {} - keyPair.pairBuffers.publicKey = bip32.fromBase58(this.xpub).derive(this.account).derive(index).publicKey - keyPair.rawAddress.publicKey = bip32.fromBase58(this.xpub).derive(this.account).derive(index).publicKey + keyPair.pairBuffers.publicKey = bip32.fromBase58(this.xpub).derive(this.change).derive(index).publicKey + keyPair.rawAddress.publicKey = bip32.fromBase58(this.xpub).derive(this.change).derive(index).publicKey keyPair.privKey = "" } @@ -413,7 +413,7 @@ class AddressGenerator { keyPair.rawPair = this.root.derivePath(keyPair.path) } else { keyPair.rawPair = {} - keyPair.rawPair.publicKey = bip32.fromBase58(this.xpub).derive(this.account).derive(index).publicKey + keyPair.rawPair.publicKey = bip32.fromBase58(this.xpub).derive(this.change).derive(index).publicKey } let ethPubkey = ethreumUtil.importPublic(keyPair.rawPair.publicKey) @@ -441,7 +441,7 @@ class AddressGenerator { keyPair.ECPair = bitcoin.ECPair.fromPrivateKey(keyPair.rawPair.privateKey, { network: this.coin.network.p2pkh, compressed: false }) } else { keyPair.rawPair = {} - keyPair.rawPair.publicKey = bip32.fromBase58(this.xpub).derive(this.account).derive(index).publicKey + keyPair.rawPair.publicKey = bip32.fromBase58(this.xpub).derive(this.change).derive(index).publicKey } @@ -468,7 +468,7 @@ class AddressGenerator { keyPair.rawPair = this.root.derivePath(keyPair.path) } else { keyPair.rawPair = {} - keyPair.rawPair.publicKey = bip32.fromBase58(this.xpub).derive(this.account).derive(index).publicKey + keyPair.rawPair.publicKey = bip32.fromBase58(this.xpub).derive(this.change).derive(index).publicKey } let ethPubkey = ethreumUtil.importPublic(keyPair.rawPair.publicKey)