diff options
author | iancoleman <1281387+iancoleman@users.noreply.github.com> | 2019-12-20 15:58:26 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-20 15:58:26 +1100 |
commit | 181b5d61e308bc6b6371e753f8ac5817755c01be (patch) | |
tree | 36f40be3a5886de01fdf57a9751de46d89ceddb4 | |
parent | aa793f572f26ad20740f28040de13431c973dfb8 (diff) | |
parent | 4dfc681f71bc6d1181d24a3bd0d462bbd6b60beb (diff) | |
download | BIP39-181b5d61e308bc6b6371e753f8ac5817755c01be.tar.gz BIP39-181b5d61e308bc6b6371e753f8ac5817755c01be.tar.zst BIP39-181b5d61e308bc6b6371e753f8ac5817755c01be.zip |
Merge pull request #390 from matthewleon/bugfix/eth-xpub-derivation
Bugfix/eth xpub derivation
-rw-r--r-- | src/js/index.js | 6 | ||||
-rw-r--r-- | tests/spec/tests.js | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/js/index.js b/src/js/index.js index d843ee1..92772f6 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -1128,9 +1128,9 @@ | |||
1128 | } | 1128 | } |
1129 | // Ethereum values are different | 1129 | // Ethereum values are different |
1130 | if (networkIsEthereum()) { | 1130 | if (networkIsEthereum()) { |
1131 | var privKeyBuffer = keyPair.d.toBuffer(32); | 1131 | var pubkeyBuffer = keyPair.getPublicKeyBuffer(); |
1132 | privkey = privKeyBuffer.toString('hex'); | 1132 | var ethPubkey = libs.ethUtil.importPublic(pubkeyBuffer); |
1133 | var addressBuffer = libs.ethUtil.privateToAddress(privKeyBuffer); | 1133 | var addressBuffer = libs.ethUtil.publicToAddress(ethPubkey); |
1134 | var hexAddress = addressBuffer.toString('hex'); | 1134 | var hexAddress = addressBuffer.toString('hex'); |
1135 | var checksumAddress = libs.ethUtil.toChecksumAddress(hexAddress); | 1135 | var checksumAddress = libs.ethUtil.toChecksumAddress(hexAddress); |
1136 | address = libs.ethUtil.addHexPrefix(checksumAddress); | 1136 | address = libs.ethUtil.addHexPrefix(checksumAddress); |
diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 7710b7a..0e85ecc 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js | |||
@@ -595,7 +595,6 @@ it('Allows selection of ethereum', function(done) { | |||
595 | firstAddress: "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772", | 595 | firstAddress: "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772", |
596 | }; | 596 | }; |
597 | testNetwork(done, params); | 597 | testNetwork(done, params); |
598 | // TODO test private key and public key | ||
599 | }); | 598 | }); |
600 | it('Allows selection of slimcoin', function(done) { | 599 | it('Allows selection of slimcoin', function(done) { |
601 | var params = { | 600 | var params = { |
@@ -4341,4 +4340,20 @@ it('Generates addresses when seed is set', function(done) { | |||
4341 | }); | 4340 | }); |
4342 | }); | 4341 | }); |
4343 | 4342 | ||
4343 | // https://github.com/iancoleman/bip39/issues/169 | ||
4344 | it('Generates ethereum addresses from a public key', function(done) { | ||
4345 | var pubkey = "xpub68UK3hrMEp2jLPxPASgXSiqiUsQsUWZHCeuu6NqcJLt259LMeWzwDyufXLN1QmjLeLRY5he4QfArDDLbsXiw3xN3kFcYtyDy74BY73RPhhW"; | ||
4346 | driver.findElement(By.css('.root-key')) | ||
4347 | .sendKeys(pubkey); | ||
4348 | driver.findElement(By.css('#bip32-tab a')) | ||
4349 | .click() | ||
4350 | selectNetwork('ETH - Ethereum'); | ||
4351 | driver.sleep(generateDelay).then(function() { | ||
4352 | getFirstAddress(function(address) { | ||
4353 | expect(address).toBe("0x1Bd54748903438C7E386b4a3fCbe16237A316a98"); | ||
4354 | done(); | ||
4355 | }); | ||
4356 | }); | ||
4357 | }); | ||
4358 | |||
4344 | }); | 4359 | }); |