Public key column in table, shown as hex

This commit is contained in:
Ian Coleman
2016-11-02 12:13:21 +11:00
parent 92b46ab44f
commit 1b12b2f5f1
4 changed files with 96 additions and 4 deletions
+23 -2
View File
@@ -298,6 +298,12 @@
<button class="address-toggle">Toggle</button> <button class="address-toggle">Toggle</button>
</div> </div>
</th> </th>
<th>
<div class="input-group">
Public Key&nbsp;&nbsp;
<button class="public-key-toggle">Toggle</button>
</div>
</th>
<th> <th>
<div class="input-group"> <div class="input-group">
Private Key&nbsp;&nbsp; Private Key&nbsp;&nbsp;
@@ -442,6 +448,7 @@
<tr> <tr>
<td class="index"><span></span></td> <td class="index"><span></span></td>
<td class="address"><span></span></td> <td class="address"><span></span></td>
<td class="pubkey"><span></span></td>
<td class="privkey"><span></span></td> <td class="privkey"><span></span></td>
</tr> </tr>
</script> </script>
@@ -16172,6 +16179,7 @@ var Mnemonic = function(language) {
var showIndex = true; var showIndex = true;
var showAddress = true; var showAddress = true;
var showPubKey = true;
var showPrivKey = true; var showPrivKey = true;
var phraseChangeTimeoutEvent = null; var phraseChangeTimeoutEvent = null;
@@ -16206,6 +16214,7 @@ var Mnemonic = function(language) {
DOM.tab = $(".derivation-type a"); DOM.tab = $(".derivation-type a");
DOM.indexToggle = $(".index-toggle"); DOM.indexToggle = $(".index-toggle");
DOM.addressToggle = $(".address-toggle"); DOM.addressToggle = $(".address-toggle");
DOM.publicKeyToggle = $(".public-key-toggle");
DOM.privateKeyToggle = $(".private-key-toggle"); DOM.privateKeyToggle = $(".private-key-toggle");
DOM.languages = $(".languages a"); DOM.languages = $(".languages a");
@@ -16226,6 +16235,7 @@ var Mnemonic = function(language) {
DOM.hardenedAddresses.on("change", calcForDerivationPath); DOM.hardenedAddresses.on("change", calcForDerivationPath);
DOM.indexToggle.on("click", toggleIndexes); DOM.indexToggle.on("click", toggleIndexes);
DOM.addressToggle.on("click", toggleAddresses); DOM.addressToggle.on("click", toggleAddresses);
DOM.publicKeyToggle.on("click", togglePublicKeys);
DOM.privateKeyToggle.on("click", togglePrivateKeys); DOM.privateKeyToggle.on("click", togglePrivateKeys);
DOM.languages.on("click", languageChanged); DOM.languages.on("click", languageChanged);
disableForms(); disableForms();
@@ -16362,6 +16372,11 @@ var Mnemonic = function(language) {
$("td.address span").toggleClass("invisible"); $("td.address span").toggleClass("invisible");
} }
function togglePublicKeys() {
showPubKey = !showPubKey;
$("td.pubkey span").toggleClass("invisible");
}
function togglePrivateKeys() { function togglePrivateKeys() {
showPrivKey = !showPrivKey; showPrivKey = !showPrivKey;
$("td.privkey span").toggleClass("invisible"); $("td.privkey span").toggleClass("invisible");
@@ -16560,11 +16575,12 @@ var Mnemonic = function(language) {
} }
var address = key.getAddress().toString(); var address = key.getAddress().toString();
var privkey = key.privKey.toWIF(network); var privkey = key.privKey.toWIF(network);
var pubkey = key.pubKey.toHex();
var indexText = getDerivationPath() + "/" + index; var indexText = getDerivationPath() + "/" + index;
if (useHardenedAddresses) { if (useHardenedAddresses) {
indexText = indexText + "'"; indexText = indexText + "'";
} }
addAddressToList(indexText, address, privkey); addAddressToList(indexText, address, pubkey, privkey);
}, 50) }, 50)
} }
@@ -16605,15 +16621,17 @@ var Mnemonic = function(language) {
DOM.extendedPubKey.val(""); DOM.extendedPubKey.val("");
} }
function addAddressToList(indexText, address, privkey) { function addAddressToList(indexText, address, pubkey, privkey) {
var row = $(addressRowTemplate.html()); var row = $(addressRowTemplate.html());
// Elements // Elements
var indexCell = row.find(".index span"); var indexCell = row.find(".index span");
var addressCell = row.find(".address span"); var addressCell = row.find(".address span");
var pubkeyCell = row.find(".pubkey span");
var privkeyCell = row.find(".privkey span"); var privkeyCell = row.find(".privkey span");
// Content // Content
indexCell.text(indexText); indexCell.text(indexText);
addressCell.text(address); addressCell.text(address);
pubkeyCell.text(pubkey);
privkeyCell.text(privkey); privkeyCell.text(privkey);
// Visibility // Visibility
if (!showIndex) { if (!showIndex) {
@@ -16622,6 +16640,9 @@ var Mnemonic = function(language) {
if (!showAddress) { if (!showAddress) {
addressCell.addClass("invisible"); addressCell.addClass("invisible");
} }
if (!showPubKey) {
pubkeyCell.addClass("invisible");
}
if (!showPrivKey) { if (!showPrivKey) {
privkeyCell.addClass("invisible"); privkeyCell.addClass("invisible");
} }
+7
View File
@@ -294,6 +294,12 @@
<button class="address-toggle">Toggle</button> <button class="address-toggle">Toggle</button>
</div> </div>
</th> </th>
<th>
<div class="input-group">
Public Key&nbsp;&nbsp;
<button class="public-key-toggle">Toggle</button>
</div>
</th>
<th> <th>
<div class="input-group"> <div class="input-group">
Private Key&nbsp;&nbsp; Private Key&nbsp;&nbsp;
@@ -438,6 +444,7 @@
<tr> <tr>
<td class="index"><span></span></td> <td class="index"><span></span></td>
<td class="address"><span></span></td> <td class="address"><span></span></td>
<td class="pubkey"><span></span></td>
<td class="privkey"><span></span></td> <td class="privkey"><span></span></td>
</tr> </tr>
</script> </script>
+16 -2
View File
@@ -11,6 +11,7 @@
var showIndex = true; var showIndex = true;
var showAddress = true; var showAddress = true;
var showPubKey = true;
var showPrivKey = true; var showPrivKey = true;
var phraseChangeTimeoutEvent = null; var phraseChangeTimeoutEvent = null;
@@ -45,6 +46,7 @@
DOM.tab = $(".derivation-type a"); DOM.tab = $(".derivation-type a");
DOM.indexToggle = $(".index-toggle"); DOM.indexToggle = $(".index-toggle");
DOM.addressToggle = $(".address-toggle"); DOM.addressToggle = $(".address-toggle");
DOM.publicKeyToggle = $(".public-key-toggle");
DOM.privateKeyToggle = $(".private-key-toggle"); DOM.privateKeyToggle = $(".private-key-toggle");
DOM.languages = $(".languages a"); DOM.languages = $(".languages a");
@@ -65,6 +67,7 @@
DOM.hardenedAddresses.on("change", calcForDerivationPath); DOM.hardenedAddresses.on("change", calcForDerivationPath);
DOM.indexToggle.on("click", toggleIndexes); DOM.indexToggle.on("click", toggleIndexes);
DOM.addressToggle.on("click", toggleAddresses); DOM.addressToggle.on("click", toggleAddresses);
DOM.publicKeyToggle.on("click", togglePublicKeys);
DOM.privateKeyToggle.on("click", togglePrivateKeys); DOM.privateKeyToggle.on("click", togglePrivateKeys);
DOM.languages.on("click", languageChanged); DOM.languages.on("click", languageChanged);
disableForms(); disableForms();
@@ -201,6 +204,11 @@
$("td.address span").toggleClass("invisible"); $("td.address span").toggleClass("invisible");
} }
function togglePublicKeys() {
showPubKey = !showPubKey;
$("td.pubkey span").toggleClass("invisible");
}
function togglePrivateKeys() { function togglePrivateKeys() {
showPrivKey = !showPrivKey; showPrivKey = !showPrivKey;
$("td.privkey span").toggleClass("invisible"); $("td.privkey span").toggleClass("invisible");
@@ -399,11 +407,12 @@
} }
var address = key.getAddress().toString(); var address = key.getAddress().toString();
var privkey = key.privKey.toWIF(network); var privkey = key.privKey.toWIF(network);
var pubkey = key.pubKey.toHex();
var indexText = getDerivationPath() + "/" + index; var indexText = getDerivationPath() + "/" + index;
if (useHardenedAddresses) { if (useHardenedAddresses) {
indexText = indexText + "'"; indexText = indexText + "'";
} }
addAddressToList(indexText, address, privkey); addAddressToList(indexText, address, pubkey, privkey);
}, 50) }, 50)
} }
@@ -444,15 +453,17 @@
DOM.extendedPubKey.val(""); DOM.extendedPubKey.val("");
} }
function addAddressToList(indexText, address, privkey) { function addAddressToList(indexText, address, pubkey, privkey) {
var row = $(addressRowTemplate.html()); var row = $(addressRowTemplate.html());
// Elements // Elements
var indexCell = row.find(".index span"); var indexCell = row.find(".index span");
var addressCell = row.find(".address span"); var addressCell = row.find(".address span");
var pubkeyCell = row.find(".pubkey span");
var privkeyCell = row.find(".privkey span"); var privkeyCell = row.find(".privkey span");
// Content // Content
indexCell.text(indexText); indexCell.text(indexText);
addressCell.text(address); addressCell.text(address);
pubkeyCell.text(pubkey);
privkeyCell.text(privkey); privkeyCell.text(privkey);
// Visibility // Visibility
if (!showIndex) { if (!showIndex) {
@@ -461,6 +472,9 @@
if (!showAddress) { if (!showAddress) {
addressCell.addClass("invisible"); addressCell.addClass("invisible");
} }
if (!showPubKey) {
pubkeyCell.addClass("invisible");
}
if (!showPrivKey) { if (!showPrivKey) {
privkeyCell.addClass("invisible"); privkeyCell.addClass("invisible");
} }
+50
View File
@@ -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 // Private key is shown
function() { function() {
page.open(url, function(status) { page.open(url, function(status) {