X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Findex.js;h=80c7fa87d7c1efbc92757a8f60c42fc657e4c03c;hb=3abab9b0874904f610cfeb7d136e97ca0ebac1e1;hp=2e14a40be720ef8a0fe79dd09251790a2fcd72e3;hpb=ed6d9d3905aa581f1a76d37d601c6be39954d1ff;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/index.js b/src/js/index.js index 2e14a40..80c7fa8 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -14,6 +14,7 @@ var showPubKey = true; var showPrivKey = true; var showQr = false; + var litecoinUseLtub = false; var entropyChangeTimeoutEvent = null; var phraseChangeTimeoutEvent = null; @@ -43,6 +44,8 @@ DOM.generate = $(".generate"); DOM.seed = $(".seed"); DOM.rootKey = $(".root-key"); + DOM.litecoinLtubContainer = $(".litecoin-ltub-container"); + DOM.litecoinUseLtub = $(".litecoin-use-ltub"); DOM.extendedPrivKey = $(".extended-priv-key"); DOM.extendedPubKey = $(".extended-pub-key"); DOM.bip32tab = $("#bip32-tab"); @@ -98,6 +101,7 @@ DOM.generate.on("click", generateClicked); DOM.more.on("click", showMore); DOM.rootKey.on("input", delayedRootKeyChanged); + DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); DOM.bip32path.on("input", calcForDerivationPath); DOM.bip44account.on("input", calcForDerivationPath); DOM.bip44change.on("input", calcForDerivationPath); @@ -123,6 +127,7 @@ function networkChanged(e) { clearDerivedKeys(); clearAddressesList(); + DOM.litecoinLtubContainer.addClass("hidden"); var networkIndex = e.target.value; var network = networks[networkIndex]; network.onSelect(); @@ -188,7 +193,6 @@ function phraseChanged() { showPending(); - hideValidationError(); setMnemonicLanguage(); // Get the mnemonic phrase var phrase = DOM.phrase.val(); @@ -201,7 +205,6 @@ var passphrase = DOM.passphrase.val(); calcBip32RootKeyFromSeed(phrase, passphrase); calcForDerivationPath(); - hidePending(); } function delayedEntropyChanged() { @@ -276,11 +279,21 @@ calcForDerivationPath(); } + function litecoinUseLtubChanged() { + litecoinUseLtub = DOM.litecoinUseLtub.prop("checked"); + if (litecoinUseLtub) { + network = bitcoinjs.bitcoin.networks.litecoinLtub; + } + else { + network = bitcoinjs.bitcoin.networks.litecoin; + } + phraseChanged(); + } + function calcForDerivationPath() { - showPending(); clearDerivedKeys(); clearAddressesList(); - hideValidationError(); + showPending(); // Don't show bip49 if it's selected but network doesn't support it if (bip49TabSelected() && !networkHasBip49()) { return; @@ -300,7 +313,6 @@ displayBip49Info(); } displayBip32Info(); - hidePending(); } function generateClicked() { @@ -536,7 +548,9 @@ return "No root key"; } // Check no hardened derivation path when using xpub keys - var hardened = path.indexOf("'") > -1; + var hardenedPath = path.indexOf("'") > -1; + var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked"); + var hardened = hardenedPath || hardenedAddresses; var isXpubkey = bip32RootKey.isNeutered(); if (hardened && isXpubkey) { return "Hardened derivation path is invalid with xpub key"; @@ -607,17 +621,19 @@ for (var i=0; i