Skip to content

Commit

Permalink
Merge pull request #1 from mhz987/xpub
Browse files Browse the repository at this point in the history
Merged fix where account value was used instead of internal/external value when deriving addresses from xpub.
  • Loading branch information
tboydston authored Feb 9, 2022
2 parents 4bfeb44 + a2c93b0 commit 0267d84
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hdAddressGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""

}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}


Expand All @@ -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)
Expand Down

0 comments on commit 0267d84

Please sign in to comment.