X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjs%2Findex.js;h=29cf06beca3009f30fbda9ba79218dacaa5ebc2a;hb=18f160099d4a319290501d9a5efb633e2acf53c9;hp=4c947a4e215703704d7830956be7d6ad075b8ebd;hpb=49b21f122a232330f7efc499095d8d80f7895a20;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/index.js b/src/js/index.js index 4c947a4..29cf06b 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -23,6 +23,7 @@ var DOM = {}; DOM.network = $(".network"); + DOM.bip32Client = $("#bip32-client"); DOM.phraseNetwork = $("#network-phrase"); DOM.useEntropy = $(".use-entropy"); DOM.entropyContainer = $(".entropy-container"); @@ -77,6 +78,7 @@ function init() { // Events DOM.network.on("change", networkChanged); + DOM.bip32Client.on("change", bip32ClientChanged); DOM.useEntropy.on("change", setEntropyVisibility); DOM.entropy.on("input", delayedEntropyChanged); DOM.entropyMnemonicLength.on("change", entropyChanged); @@ -102,6 +104,7 @@ hidePending(); hideValidationError(); populateNetworkSelect(); + populateClientSelect(); } // Event handlers @@ -117,6 +120,23 @@ } } + function bip32ClientChanged(e) { + var clientIndex = DOM.bip32Client.val(); + if (clientIndex == "custom") { + DOM.bip32path.prop("readonly", false); + } + else { + DOM.bip32path.prop("readonly", true); + clients[clientIndex].onSelect(); + if (seed != null) { + phraseChanged(); + } + else { + rootKeyChanged(); + } + } + } + function setEntropyVisibility() { if (isUsingOwnEntropy()) { DOM.entropyContainer.removeClass("hidden"); @@ -711,6 +731,16 @@ } } + function populateClientSelect() { + for (var i=0; i"); + option.attr("value", i); + option.text(client.name); + DOM.bip32Client.append(option); + } + } + function getLanguage() { var defaultLanguage = "english"; // Try to get from existing phrase @@ -1141,6 +1171,30 @@ }, ] + var clients = [ + { + name: "Bitcoin Core", + onSelect: function() { + DOM.bip32path.val("m/0'/0'"); + DOM.hardenedAddresses.prop('checked', true); + }, + }, + { + name: "blockchain.info", + onSelect: function() { + DOM.bip32path.val("m/44'/0'/0'"); + DOM.hardenedAddresses.prop('checked', false); + }, + }, + { + name: "MultiBit HD", + onSelect: function() { + DOM.bip32path.val("m/0'/0"); + DOM.hardenedAddresses.prop('checked', false); + }, + } + ] + init(); })();