aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2017-02-15 19:45:03 +1100
committerIan Coleman <coleman.ian@gmail.com>2017-02-15 19:45:03 +1100
commit49b21f122a232330f7efc499095d8d80f7895a20 (patch)
tree113cf9781c910a4f015c4b5f488ffeb8d9d4aeb8
parent8b095871e8ab14ec236ddb181ffdfe36e6636058 (diff)
downloadBIP39-49b21f122a232330f7efc499095d8d80f7895a20.tar.gz
BIP39-49b21f122a232330f7efc499095d8d80f7895a20.tar.zst
BIP39-49b21f122a232330f7efc499095d8d80f7895a20.zip
Ethereum addresses include checksum
-rw-r--r--bip39-standalone.html4
-rw-r--r--src/js/index.js4
-rw-r--r--tests.js4
3 files changed, 8 insertions, 4 deletions
diff --git a/bip39-standalone.html b/bip39-standalone.html
index 0d1d244..de74d80 100644
--- a/bip39-standalone.html
+++ b/bip39-standalone.html
@@ -41770,7 +41770,9 @@ window.Entropy = new (function() {
41770 var privKeyBuffer = key.privKey.d.toBuffer(); 41770 var privKeyBuffer = key.privKey.d.toBuffer();
41771 privkey = privKeyBuffer.toString('hex'); 41771 privkey = privKeyBuffer.toString('hex');
41772 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer); 41772 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
41773 address = "0x" + addressBuffer.toString('hex'); 41773 var hexAddress = addressBuffer.toString('hex');
41774 var checksumAddress = ethUtil.toChecksumAddress(hexAddress);
41775 address = ethUtil.addHexPrefix(checksumAddress);
41774 } 41776 }
41775 addAddressToList(indexText, address, pubkey, privkey); 41777 addAddressToList(indexText, address, pubkey, privkey);
41776 }, 50) 41778 }, 50)
diff --git a/src/js/index.js b/src/js/index.js
index 41f8260..4c947a4 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -569,7 +569,9 @@
569 var privKeyBuffer = key.privKey.d.toBuffer(); 569 var privKeyBuffer = key.privKey.d.toBuffer();
570 privkey = privKeyBuffer.toString('hex'); 570 privkey = privKeyBuffer.toString('hex');
571 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer); 571 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
572 address = "0x" + addressBuffer.toString('hex'); 572 var hexAddress = addressBuffer.toString('hex');
573 var checksumAddress = ethUtil.toChecksumAddress(hexAddress);
574 address = ethUtil.addHexPrefix(checksumAddress);
573 } 575 }
574 addAddressToList(indexText, address, pubkey, privkey); 576 addAddressToList(indexText, address, pubkey, privkey);
575 }, 50) 577 }, 50)
diff --git a/tests.js b/tests.js
index 677f3e2..89f4ce3 100644
--- a/tests.js
+++ b/tests.js
@@ -624,12 +624,12 @@ page.open(url, function(status) {
624 // check the address is generated correctly 624 // check the address is generated correctly
625 // this value comes from 625 // this value comes from
626 // https://www.myetherwallet.com/#view-wallet-info 626 // https://www.myetherwallet.com/#view-wallet-info
627 // I do not understand the capitalization scheme for this hex encoding 627 // Unusual capitalization is due to checksum
628 var expected = "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772"; 628 var expected = "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772";
629 var actual = page.evaluate(function() { 629 var actual = page.evaluate(function() {
630 return $(".address:first").text(); 630 return $(".address:first").text();
631 }); 631 });
632 if (actual != expected.toLowerCase()) { 632 if (actual != expected) {
633 console.log("Ethereum address is incorrect"); 633 console.log("Ethereum address is incorrect");
634 console.log("Expected: " + expected); 634 console.log("Expected: " + expected);
635 console.log("Actual: " + actual); 635 console.log("Actual: " + actual);