]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Public key column in table, shown as hex
authorIan Coleman <coleman.ian@gmail.com>
Wed, 2 Nov 2016 01:13:21 +0000 (12:13 +1100)
committerIan Coleman <coleman.ian@gmail.com>
Wed, 2 Nov 2016 01:13:21 +0000 (12:13 +1100)
bip39-standalone.html
src/index.html
src/js/index.js
tests.js

index bb3ea38798d01a2b67582f9adc86b5a5b7de6d17..62bd43c7a17c8c21d7d804c1766fb8d291eef5b6 100644 (file)
                                     <button class="address-toggle">Toggle</button>
                                 </div>
                             </th>
+                            <th>
+                                <div class="input-group">
+                                    Public Key&nbsp;&nbsp;
+                                    <button class="public-key-toggle">Toggle</button>
+                                </div>
+                            </th>
                             <th>
                                 <div class="input-group">
                                     Private Key&nbsp;&nbsp;
             <tr>
                 <td class="index"><span></span></td>
                 <td class="address"><span></span></td>
+                <td class="pubkey"><span></span></td>
                 <td class="privkey"><span></span></td>
             </tr>
         </script>
@@ -16172,6 +16179,7 @@ var Mnemonic = function(language) {
 
     var showIndex = true;
     var showAddress = true;
+    var showPubKey = true;
     var showPrivKey = true;
 
     var phraseChangeTimeoutEvent = null;
@@ -16206,6 +16214,7 @@ var Mnemonic = function(language) {
     DOM.tab = $(".derivation-type a");
     DOM.indexToggle = $(".index-toggle");
     DOM.addressToggle = $(".address-toggle");
+    DOM.publicKeyToggle = $(".public-key-toggle");
     DOM.privateKeyToggle = $(".private-key-toggle");
     DOM.languages = $(".languages a");
 
@@ -16226,6 +16235,7 @@ var Mnemonic = function(language) {
         DOM.hardenedAddresses.on("change", calcForDerivationPath);
         DOM.indexToggle.on("click", toggleIndexes);
         DOM.addressToggle.on("click", toggleAddresses);
+        DOM.publicKeyToggle.on("click", togglePublicKeys);
         DOM.privateKeyToggle.on("click", togglePrivateKeys);
         DOM.languages.on("click", languageChanged);
         disableForms();
@@ -16362,6 +16372,11 @@ var Mnemonic = function(language) {
         $("td.address span").toggleClass("invisible");
     }
 
+    function togglePublicKeys() {
+        showPubKey = !showPubKey;
+        $("td.pubkey span").toggleClass("invisible");
+    }
+
     function togglePrivateKeys() {
         showPrivKey = !showPrivKey;
         $("td.privkey span").toggleClass("invisible");
@@ -16560,11 +16575,12 @@ var Mnemonic = function(language) {
                 }
                 var address = key.getAddress().toString();
                 var privkey = key.privKey.toWIF(network);
+                var pubkey = key.pubKey.toHex();
                 var indexText = getDerivationPath() + "/" + index;
                 if (useHardenedAddresses) {
                     indexText = indexText + "'";
                 }
-                addAddressToList(indexText, address, privkey);
+                addAddressToList(indexText, address, pubkey, privkey);
             }, 50)
         }
 
@@ -16605,15 +16621,17 @@ var Mnemonic = function(language) {
         DOM.extendedPubKey.val("");
     }
 
-    function addAddressToList(indexText, address, privkey) {
+    function addAddressToList(indexText, address, pubkey, privkey) {
         var row = $(addressRowTemplate.html());
         // Elements
         var indexCell = row.find(".index span");
         var addressCell = row.find(".address span");
+        var pubkeyCell = row.find(".pubkey span");
         var privkeyCell = row.find(".privkey span");
         // Content
         indexCell.text(indexText);
         addressCell.text(address);
+        pubkeyCell.text(pubkey);
         privkeyCell.text(privkey);
         // Visibility
         if (!showIndex) {
@@ -16622,6 +16640,9 @@ var Mnemonic = function(language) {
         if (!showAddress) {
             addressCell.addClass("invisible");
         }
+        if (!showPubKey) {
+            pubkeyCell.addClass("invisible");
+        }
         if (!showPrivKey) {
             privkeyCell.addClass("invisible");
         }
index b24b4d4d4d325343aff2c0690cc6cc04ee68768c..5832a9b8f278c75a83e2529219963256cc7c22fc 100644 (file)
                                     <button class="address-toggle">Toggle</button>
                                 </div>
                             </th>
+                            <th>
+                                <div class="input-group">
+                                    Public Key&nbsp;&nbsp;
+                                    <button class="public-key-toggle">Toggle</button>
+                                </div>
+                            </th>
                             <th>
                                 <div class="input-group">
                                     Private Key&nbsp;&nbsp;
             <tr>
                 <td class="index"><span></span></td>
                 <td class="address"><span></span></td>
+                <td class="pubkey"><span></span></td>
                 <td class="privkey"><span></span></td>
             </tr>
         </script>
index c5f6c111fa61e4c38695939a1106a8afcb94396d..0e4cc052a4d704fa749bf9076c9bc68fc5145530 100644 (file)
@@ -11,6 +11,7 @@
 
     var showIndex = true;
     var showAddress = true;
+    var showPubKey = true;
     var showPrivKey = true;
 
     var phraseChangeTimeoutEvent = null;
@@ -45,6 +46,7 @@
     DOM.tab = $(".derivation-type a");
     DOM.indexToggle = $(".index-toggle");
     DOM.addressToggle = $(".address-toggle");
+    DOM.publicKeyToggle = $(".public-key-toggle");
     DOM.privateKeyToggle = $(".private-key-toggle");
     DOM.languages = $(".languages a");
 
@@ -65,6 +67,7 @@
         DOM.hardenedAddresses.on("change", calcForDerivationPath);
         DOM.indexToggle.on("click", toggleIndexes);
         DOM.addressToggle.on("click", toggleAddresses);
+        DOM.publicKeyToggle.on("click", togglePublicKeys);
         DOM.privateKeyToggle.on("click", togglePrivateKeys);
         DOM.languages.on("click", languageChanged);
         disableForms();
         $("td.address span").toggleClass("invisible");
     }
 
+    function togglePublicKeys() {
+        showPubKey = !showPubKey;
+        $("td.pubkey span").toggleClass("invisible");
+    }
+
     function togglePrivateKeys() {
         showPrivKey = !showPrivKey;
         $("td.privkey span").toggleClass("invisible");
                 }
                 var address = key.getAddress().toString();
                 var privkey = key.privKey.toWIF(network);
+                var pubkey = key.pubKey.toHex();
                 var indexText = getDerivationPath() + "/" + index;
                 if (useHardenedAddresses) {
                     indexText = indexText + "'";
                 }
-                addAddressToList(indexText, address, privkey);
+                addAddressToList(indexText, address, pubkey, privkey);
             }, 50)
         }
 
         DOM.extendedPubKey.val("");
     }
 
-    function addAddressToList(indexText, address, privkey) {
+    function addAddressToList(indexText, address, pubkey, privkey) {
         var row = $(addressRowTemplate.html());
         // Elements
         var indexCell = row.find(".index span");
         var addressCell = row.find(".address span");
+        var pubkeyCell = row.find(".pubkey span");
         var privkeyCell = row.find(".privkey span");
         // Content
         indexCell.text(indexText);
         addressCell.text(address);
+        pubkeyCell.text(pubkey);
         privkeyCell.text(privkey);
         // Visibility
         if (!showIndex) {
         if (!showAddress) {
             addressCell.addClass("invisible");
         }
+        if (!showPubKey) {
+            pubkeyCell.addClass("invisible");
+        }
         if (!showPrivKey) {
             privkeyCell.addClass("invisible");
         }
index ebdf9ec78d89231c13e7aad26991ba6e1118f276..914be245532a28eb921bf3e36ec8207b78a60204 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -1166,6 +1166,56 @@ page.open(url, function(status) {
 });
 },
 
+// Public key is shown
+function() {
+page.open(url, function(status) {
+    var expected = "033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3";
+    // set the phrase
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability").trigger("input");
+    });
+    // get the address
+    waitForGenerate(function() {
+        var actual = page.evaluate(function() {
+            return $(".pubkey:first").text();
+        });
+        if (actual != expected) {
+            console.log("Public key is not shown");
+            console.log("Expected: " + expected);
+            console.log("Got: " + actual);
+            fail();
+        }
+        next();
+    });
+});
+},
+
+// Public key visibility can be toggled
+function() {
+page.open(url, function(status) {
+    // set the phrase
+    page.evaluate(function() {
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+    });
+    waitForGenerate(function() {
+        // toggle public key visibility
+        page.evaluate(function() {
+            $(".public-key-toggle").click();
+        });
+        // check the public key is not visible
+        var isInvisible = page.evaluate(function() {
+            return $(".pubkey:first span").hasClass("invisible");
+        });
+        if (!isInvisible) {
+            console.log("Toggled public key is visible");
+            fail();
+        }
+        next();
+    });
+});
+},
+
 // Private key is shown
 function() {
 page.open(url, function(status) {