Skip to content

Commit

Permalink
fix: getAddressByPath bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wang committed Aug 3, 2020
1 parent c8ca3e8 commit 0220cc1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/base/address.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = class Address {

getCoinAddressKeyPair(index, account, change) {
let {path, pri, pub} = this.getCoinKeyPair(index, account, change);
let {address} = this.getAddress(index, account, change)
let {address} = this.getAddressByPublicKey(pub)
return {address, path, pri: pri.toString("hex"), pub: pub.toString("hex")};
};

Expand Down
14 changes: 13 additions & 1 deletion test/lib/eth.address.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@ describe("ETH", () => {
// m/account'/change/address_index
it("Eth getAddressByPath", () => {
let addr = new EthAddr(hd)
let {address, pub, pri, path} = addr.getAddressByPath("m/20'/0/" + hdData.index)
let {address, pub, pri, path} = addr.getAddressByPath("m/20'/0/" + 3)
console.log(address, pub, pri, path)
let validAddress = addrValid(addr.coin, address)
console.assert(validAddress, "address invalid")
console.assert(address == hdData.ETH, "address is diff")

})

it("Eth getAddressByPrivateKey", () => {
let addr = new EthAddr(hd)
let {address, pub, pri, path} = addr.getAddressByPrivateKey("93b1302f88019cfd120f83677274447ae76112be7e31b6aee59928fbb9a12584")
console.log(address, pub, pri, path)
let validAddress = addrValid(addr.coin, address)
console.assert(validAddress, "address invalid")
console.assert(address == hdData.ETH, "address is diff")

})


})

0 comments on commit 0220cc1

Please sign in to comment.