var network = Bitcoin.networks.bitcoin;
var addressRowTemplate = $("#address-row-template");
+ var showIndex = true;
+ var showAddress = true;
+ var showPrivKey = true;
+
var phraseChangeTimeoutEvent = null;
var DOM = {};
+ DOM.network = $(".network");
+ DOM.phraseNetwork = $("#network-phrase");
DOM.phrase = $(".phrase");
DOM.passphrase = $(".passphrase");
DOM.generate = $(".generate");
DOM.rootKey = $(".root-key");
DOM.extendedPrivKey = $(".extended-priv-key");
DOM.extendedPubKey = $(".extended-pub-key");
+ DOM.bip32tab = $("#bip32-tab");
+ DOM.bip44tab = $("#bip44-tab");
+ DOM.bip32panel = $("#bip32");
+ DOM.bip44panel = $("#bip44");
DOM.bip32path = $("#bip32-path");
DOM.bip44path = $("#bip44-path");
DOM.bip44purpose = $("#bip44 .purpose");
function init() {
// Events
+ DOM.network.on("change", networkChanged);
DOM.phrase.on("input", delayedPhraseChanged);
DOM.passphrase.on("input", delayedPhraseChanged);
DOM.generate.on("click", generateClicked);
// Event handlers
+ function networkChanged(e) {
+ var n = e.target.value;
+ if (n == "bitcoin") {
+ network = Bitcoin.networks.bitcoin;
+ DOM.bip44coin.val(0);
+ }
+ else if (n == "bitcoin-testnet") {
+ network = Bitcoin.networks.testnet;
+ DOM.bip44coin.val(1);
+ }
+ else if (n == "litecoin") {
+ network = Bitcoin.networks.litecoin;
+ DOM.bip44coin.val(2);
+ }
+ else if (n == "dogecoin") {
+ network = Bitcoin.networks.dogecoin;
+ var UNOFFICIAL_BIP44_COIN = 9999;
+ DOM.bip44coin.val(UNOFFICIAL_BIP44_COIN); // This coin is not in BIP44
+ }
+ setBip44DerivationPath();
+ delayedPhraseChanged();
+ }
+
function delayedPhraseChanged() {
hideValidationError();
showPending();
}
function toggleIndexes() {
+ showIndex = !showIndex;
$("td.index span").toggleClass("invisible");
}
function toggleAddresses() {
+ showAddress = !showAddress;
$("td.address span").toggleClass("invisible");
}
function togglePrivateKeys() {
+ showPrivKey = !showPrivKey;
$("td.privkey span").toggleClass("invisible");
}
function addAddressToList(index, address, privkey) {
var row = $(addressRowTemplate.html());
- row.find(".index span").text(index);
- row.find(".address span").text(address);
- row.find(".privkey span").text(privkey);
+ // Elements
+ var indexCell = row.find(".index span");
+ var addressCell = row.find(".address span");
+ var privkeyCell = row.find(".privkey span");
+ // Content
+ indexCell.text(index);
+ addressCell.text(address);
+ privkeyCell.text(privkey);
+ // Visibility
+ if (!showIndex) {
+ indexCell.addClass("invisible");
+ }
+ if (!showAddress) {
+ addressCell.addClass("invisible");
+ }
+ if (!showPrivKey) {
+ privkeCell.addClass("invisible");
+ }
DOM.addresses.append(row);
}