diff options
-rw-r--r-- | bip39-standalone.html | 25 | ||||
-rw-r--r-- | src/index.html | 7 | ||||
-rw-r--r-- | src/js/index.js | 18 | ||||
-rw-r--r-- | tests.js | 50 |
4 files changed, 96 insertions, 4 deletions
diff --git a/bip39-standalone.html b/bip39-standalone.html index bb3ea38..62bd43c 100644 --- a/bip39-standalone.html +++ b/bip39-standalone.html | |||
@@ -300,6 +300,12 @@ | |||
300 | </th> | 300 | </th> |
301 | <th> | 301 | <th> |
302 | <div class="input-group"> | 302 | <div class="input-group"> |
303 | Public Key | ||
304 | <button class="public-key-toggle">Toggle</button> | ||
305 | </div> | ||
306 | </th> | ||
307 | <th> | ||
308 | <div class="input-group"> | ||
303 | Private Key | 309 | Private Key |
304 | <button class="private-key-toggle">Toggle</button> | 310 | <button class="private-key-toggle">Toggle</button> |
305 | </div> | 311 | </div> |
@@ -442,6 +448,7 @@ | |||
442 | <tr> | 448 | <tr> |
443 | <td class="index"><span></span></td> | 449 | <td class="index"><span></span></td> |
444 | <td class="address"><span></span></td> | 450 | <td class="address"><span></span></td> |
451 | <td class="pubkey"><span></span></td> | ||
445 | <td class="privkey"><span></span></td> | 452 | <td class="privkey"><span></span></td> |
446 | </tr> | 453 | </tr> |
447 | </script> | 454 | </script> |
@@ -16172,6 +16179,7 @@ var Mnemonic = function(language) { | |||
16172 | 16179 | ||
16173 | var showIndex = true; | 16180 | var showIndex = true; |
16174 | var showAddress = true; | 16181 | var showAddress = true; |
16182 | var showPubKey = true; | ||
16175 | var showPrivKey = true; | 16183 | var showPrivKey = true; |
16176 | 16184 | ||
16177 | var phraseChangeTimeoutEvent = null; | 16185 | var phraseChangeTimeoutEvent = null; |
@@ -16206,6 +16214,7 @@ var Mnemonic = function(language) { | |||
16206 | DOM.tab = $(".derivation-type a"); | 16214 | DOM.tab = $(".derivation-type a"); |
16207 | DOM.indexToggle = $(".index-toggle"); | 16215 | DOM.indexToggle = $(".index-toggle"); |
16208 | DOM.addressToggle = $(".address-toggle"); | 16216 | DOM.addressToggle = $(".address-toggle"); |
16217 | DOM.publicKeyToggle = $(".public-key-toggle"); | ||
16209 | DOM.privateKeyToggle = $(".private-key-toggle"); | 16218 | DOM.privateKeyToggle = $(".private-key-toggle"); |
16210 | DOM.languages = $(".languages a"); | 16219 | DOM.languages = $(".languages a"); |
16211 | 16220 | ||
@@ -16226,6 +16235,7 @@ var Mnemonic = function(language) { | |||
16226 | DOM.hardenedAddresses.on("change", calcForDerivationPath); | 16235 | DOM.hardenedAddresses.on("change", calcForDerivationPath); |
16227 | DOM.indexToggle.on("click", toggleIndexes); | 16236 | DOM.indexToggle.on("click", toggleIndexes); |
16228 | DOM.addressToggle.on("click", toggleAddresses); | 16237 | DOM.addressToggle.on("click", toggleAddresses); |
16238 | DOM.publicKeyToggle.on("click", togglePublicKeys); | ||
16229 | DOM.privateKeyToggle.on("click", togglePrivateKeys); | 16239 | DOM.privateKeyToggle.on("click", togglePrivateKeys); |
16230 | DOM.languages.on("click", languageChanged); | 16240 | DOM.languages.on("click", languageChanged); |
16231 | disableForms(); | 16241 | disableForms(); |
@@ -16362,6 +16372,11 @@ var Mnemonic = function(language) { | |||
16362 | $("td.address span").toggleClass("invisible"); | 16372 | $("td.address span").toggleClass("invisible"); |
16363 | } | 16373 | } |
16364 | 16374 | ||
16375 | function togglePublicKeys() { | ||
16376 | showPubKey = !showPubKey; | ||
16377 | $("td.pubkey span").toggleClass("invisible"); | ||
16378 | } | ||
16379 | |||
16365 | function togglePrivateKeys() { | 16380 | function togglePrivateKeys() { |
16366 | showPrivKey = !showPrivKey; | 16381 | showPrivKey = !showPrivKey; |
16367 | $("td.privkey span").toggleClass("invisible"); | 16382 | $("td.privkey span").toggleClass("invisible"); |
@@ -16560,11 +16575,12 @@ var Mnemonic = function(language) { | |||
16560 | } | 16575 | } |
16561 | var address = key.getAddress().toString(); | 16576 | var address = key.getAddress().toString(); |
16562 | var privkey = key.privKey.toWIF(network); | 16577 | var privkey = key.privKey.toWIF(network); |
16578 | var pubkey = key.pubKey.toHex(); | ||
16563 | var indexText = getDerivationPath() + "/" + index; | 16579 | var indexText = getDerivationPath() + "/" + index; |
16564 | if (useHardenedAddresses) { | 16580 | if (useHardenedAddresses) { |
16565 | indexText = indexText + "'"; | 16581 | indexText = indexText + "'"; |
16566 | } | 16582 | } |
16567 | addAddressToList(indexText, address, privkey); | 16583 | addAddressToList(indexText, address, pubkey, privkey); |
16568 | }, 50) | 16584 | }, 50) |
16569 | } | 16585 | } |
16570 | 16586 | ||
@@ -16605,15 +16621,17 @@ var Mnemonic = function(language) { | |||
16605 | DOM.extendedPubKey.val(""); | 16621 | DOM.extendedPubKey.val(""); |
16606 | } | 16622 | } |
16607 | 16623 | ||
16608 | function addAddressToList(indexText, address, privkey) { | 16624 | function addAddressToList(indexText, address, pubkey, privkey) { |
16609 | var row = $(addressRowTemplate.html()); | 16625 | var row = $(addressRowTemplate.html()); |
16610 | // Elements | 16626 | // Elements |
16611 | var indexCell = row.find(".index span"); | 16627 | var indexCell = row.find(".index span"); |
16612 | var addressCell = row.find(".address span"); | 16628 | var addressCell = row.find(".address span"); |
16629 | var pubkeyCell = row.find(".pubkey span"); | ||
16613 | var privkeyCell = row.find(".privkey span"); | 16630 | var privkeyCell = row.find(".privkey span"); |
16614 | // Content | 16631 | // Content |
16615 | indexCell.text(indexText); | 16632 | indexCell.text(indexText); |
16616 | addressCell.text(address); | 16633 | addressCell.text(address); |
16634 | pubkeyCell.text(pubkey); | ||
16617 | privkeyCell.text(privkey); | 16635 | privkeyCell.text(privkey); |
16618 | // Visibility | 16636 | // Visibility |
16619 | if (!showIndex) { | 16637 | if (!showIndex) { |
@@ -16622,6 +16640,9 @@ var Mnemonic = function(language) { | |||
16622 | if (!showAddress) { | 16640 | if (!showAddress) { |
16623 | addressCell.addClass("invisible"); | 16641 | addressCell.addClass("invisible"); |
16624 | } | 16642 | } |
16643 | if (!showPubKey) { | ||
16644 | pubkeyCell.addClass("invisible"); | ||
16645 | } | ||
16625 | if (!showPrivKey) { | 16646 | if (!showPrivKey) { |
16626 | privkeyCell.addClass("invisible"); | 16647 | privkeyCell.addClass("invisible"); |
16627 | } | 16648 | } |
diff --git a/src/index.html b/src/index.html index b24b4d4..5832a9b 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -296,6 +296,12 @@ | |||
296 | </th> | 296 | </th> |
297 | <th> | 297 | <th> |
298 | <div class="input-group"> | 298 | <div class="input-group"> |
299 | Public Key | ||
300 | <button class="public-key-toggle">Toggle</button> | ||
301 | </div> | ||
302 | </th> | ||
303 | <th> | ||
304 | <div class="input-group"> | ||
299 | Private Key | 305 | Private Key |
300 | <button class="private-key-toggle">Toggle</button> | 306 | <button class="private-key-toggle">Toggle</button> |
301 | </div> | 307 | </div> |
@@ -438,6 +444,7 @@ | |||
438 | <tr> | 444 | <tr> |
439 | <td class="index"><span></span></td> | 445 | <td class="index"><span></span></td> |
440 | <td class="address"><span></span></td> | 446 | <td class="address"><span></span></td> |
447 | <td class="pubkey"><span></span></td> | ||
441 | <td class="privkey"><span></span></td> | 448 | <td class="privkey"><span></span></td> |
442 | </tr> | 449 | </tr> |
443 | </script> | 450 | </script> |
diff --git a/src/js/index.js b/src/js/index.js index c5f6c11..0e4cc05 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | var showIndex = true; | 12 | var showIndex = true; |
13 | var showAddress = true; | 13 | var showAddress = true; |
14 | var showPubKey = true; | ||
14 | var showPrivKey = true; | 15 | var showPrivKey = true; |
15 | 16 | ||
16 | var phraseChangeTimeoutEvent = null; | 17 | var phraseChangeTimeoutEvent = null; |
@@ -45,6 +46,7 @@ | |||
45 | DOM.tab = $(".derivation-type a"); | 46 | DOM.tab = $(".derivation-type a"); |
46 | DOM.indexToggle = $(".index-toggle"); | 47 | DOM.indexToggle = $(".index-toggle"); |
47 | DOM.addressToggle = $(".address-toggle"); | 48 | DOM.addressToggle = $(".address-toggle"); |
49 | DOM.publicKeyToggle = $(".public-key-toggle"); | ||
48 | DOM.privateKeyToggle = $(".private-key-toggle"); | 50 | DOM.privateKeyToggle = $(".private-key-toggle"); |
49 | DOM.languages = $(".languages a"); | 51 | DOM.languages = $(".languages a"); |
50 | 52 | ||
@@ -65,6 +67,7 @@ | |||
65 | DOM.hardenedAddresses.on("change", calcForDerivationPath); | 67 | DOM.hardenedAddresses.on("change", calcForDerivationPath); |
66 | DOM.indexToggle.on("click", toggleIndexes); | 68 | DOM.indexToggle.on("click", toggleIndexes); |
67 | DOM.addressToggle.on("click", toggleAddresses); | 69 | DOM.addressToggle.on("click", toggleAddresses); |
70 | DOM.publicKeyToggle.on("click", togglePublicKeys); | ||
68 | DOM.privateKeyToggle.on("click", togglePrivateKeys); | 71 | DOM.privateKeyToggle.on("click", togglePrivateKeys); |
69 | DOM.languages.on("click", languageChanged); | 72 | DOM.languages.on("click", languageChanged); |
70 | disableForms(); | 73 | disableForms(); |
@@ -201,6 +204,11 @@ | |||
201 | $("td.address span").toggleClass("invisible"); | 204 | $("td.address span").toggleClass("invisible"); |
202 | } | 205 | } |
203 | 206 | ||
207 | function togglePublicKeys() { | ||
208 | showPubKey = !showPubKey; | ||
209 | $("td.pubkey span").toggleClass("invisible"); | ||
210 | } | ||
211 | |||
204 | function togglePrivateKeys() { | 212 | function togglePrivateKeys() { |
205 | showPrivKey = !showPrivKey; | 213 | showPrivKey = !showPrivKey; |
206 | $("td.privkey span").toggleClass("invisible"); | 214 | $("td.privkey span").toggleClass("invisible"); |
@@ -399,11 +407,12 @@ | |||
399 | } | 407 | } |
400 | var address = key.getAddress().toString(); | 408 | var address = key.getAddress().toString(); |
401 | var privkey = key.privKey.toWIF(network); | 409 | var privkey = key.privKey.toWIF(network); |
410 | var pubkey = key.pubKey.toHex(); | ||
402 | var indexText = getDerivationPath() + "/" + index; | 411 | var indexText = getDerivationPath() + "/" + index; |
403 | if (useHardenedAddresses) { | 412 | if (useHardenedAddresses) { |
404 | indexText = indexText + "'"; | 413 | indexText = indexText + "'"; |
405 | } | 414 | } |
406 | addAddressToList(indexText, address, privkey); | 415 | addAddressToList(indexText, address, pubkey, privkey); |
407 | }, 50) | 416 | }, 50) |
408 | } | 417 | } |
409 | 418 | ||
@@ -444,15 +453,17 @@ | |||
444 | DOM.extendedPubKey.val(""); | 453 | DOM.extendedPubKey.val(""); |
445 | } | 454 | } |
446 | 455 | ||
447 | function addAddressToList(indexText, address, privkey) { | 456 | function addAddressToList(indexText, address, pubkey, privkey) { |
448 | var row = $(addressRowTemplate.html()); | 457 | var row = $(addressRowTemplate.html()); |
449 | // Elements | 458 | // Elements |
450 | var indexCell = row.find(".index span"); | 459 | var indexCell = row.find(".index span"); |
451 | var addressCell = row.find(".address span"); | 460 | var addressCell = row.find(".address span"); |
461 | var pubkeyCell = row.find(".pubkey span"); | ||
452 | var privkeyCell = row.find(".privkey span"); | 462 | var privkeyCell = row.find(".privkey span"); |
453 | // Content | 463 | // Content |
454 | indexCell.text(indexText); | 464 | indexCell.text(indexText); |
455 | addressCell.text(address); | 465 | addressCell.text(address); |
466 | pubkeyCell.text(pubkey); | ||
456 | privkeyCell.text(privkey); | 467 | privkeyCell.text(privkey); |
457 | // Visibility | 468 | // Visibility |
458 | if (!showIndex) { | 469 | if (!showIndex) { |
@@ -461,6 +472,9 @@ | |||
461 | if (!showAddress) { | 472 | if (!showAddress) { |
462 | addressCell.addClass("invisible"); | 473 | addressCell.addClass("invisible"); |
463 | } | 474 | } |
475 | if (!showPubKey) { | ||
476 | pubkeyCell.addClass("invisible"); | ||
477 | } | ||
464 | if (!showPrivKey) { | 478 | if (!showPrivKey) { |
465 | privkeyCell.addClass("invisible"); | 479 | privkeyCell.addClass("invisible"); |
466 | } | 480 | } |
@@ -1166,6 +1166,56 @@ page.open(url, function(status) { | |||
1166 | }); | 1166 | }); |
1167 | }, | 1167 | }, |
1168 | 1168 | ||
1169 | // Public key is shown | ||
1170 | function() { | ||
1171 | page.open(url, function(status) { | ||
1172 | var expected = "033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3"; | ||
1173 | // set the phrase | ||
1174 | page.evaluate(function() { | ||
1175 | $(".phrase").val("abandon abandon ability").trigger("input"); | ||
1176 | }); | ||
1177 | // get the address | ||
1178 | waitForGenerate(function() { | ||
1179 | var actual = page.evaluate(function() { | ||
1180 | return $(".pubkey:first").text(); | ||
1181 | }); | ||
1182 | if (actual != expected) { | ||
1183 | console.log("Public key is not shown"); | ||
1184 | console.log("Expected: " + expected); | ||
1185 | console.log("Got: " + actual); | ||
1186 | fail(); | ||
1187 | } | ||
1188 | next(); | ||
1189 | }); | ||
1190 | }); | ||
1191 | }, | ||
1192 | |||
1193 | // Public key visibility can be toggled | ||
1194 | function() { | ||
1195 | page.open(url, function(status) { | ||
1196 | // set the phrase | ||
1197 | page.evaluate(function() { | ||
1198 | $(".phrase").val("abandon abandon ability"); | ||
1199 | $(".phrase").trigger("input"); | ||
1200 | }); | ||
1201 | waitForGenerate(function() { | ||
1202 | // toggle public key visibility | ||
1203 | page.evaluate(function() { | ||
1204 | $(".public-key-toggle").click(); | ||
1205 | }); | ||
1206 | // check the public key is not visible | ||
1207 | var isInvisible = page.evaluate(function() { | ||
1208 | return $(".pubkey:first span").hasClass("invisible"); | ||
1209 | }); | ||
1210 | if (!isInvisible) { | ||
1211 | console.log("Toggled public key is visible"); | ||
1212 | fail(); | ||
1213 | } | ||
1214 | next(); | ||
1215 | }); | ||
1216 | }); | ||
1217 | }, | ||
1218 | |||
1169 | // Private key is shown | 1219 | // Private key is shown |
1170 | function() { | 1220 | function() { |
1171 | page.open(url, function(status) { | 1221 | page.open(url, function(status) { |