X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Findex.js;h=f593b3a937a427e46511a036b1c3a311d35bd530;hb=b4fd763cebfb7f9497e12ca09b6271e1b39ac145;hp=af09606916b22b54d28829ca4dd68f1bfa42dd75;hpb=fef188cd1ed85b78e5f78d71e9c71f14e9e26448;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/index.js b/src/js/index.js index af09606..f593b3a 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -19,9 +19,13 @@ var phraseChangeTimeoutEvent = null; var rootKeyChangedTimeoutEvent = null; + var generationProcesses = []; + var DOM = {}; DOM.network = $(".network"); + DOM.client = $(".client"); DOM.phraseNetwork = $("#network-phrase"); + DOM.phraseClient = $("#client-phrase"); DOM.useEntropy = $(".use-entropy"); DOM.entropyContainer = $(".entropy-container"); DOM.entropy = $(".entropy"); @@ -75,6 +79,7 @@ function init() { // Events DOM.network.on("change", networkChanged); + DOM.client.on("change", clientChanged); DOM.useEntropy.on("change", setEntropyVisibility); DOM.entropy.on("input", delayedEntropyChanged); DOM.entropyMnemonicLength.on("change", entropyChanged); @@ -100,6 +105,7 @@ hidePending(); hideValidationError(); populateNetworkSelect(); + populateClientSelect(); } // Event handlers @@ -114,6 +120,17 @@ rootKeyChanged(); } } + + function clientChanged(e) { + var clientIndex = e.target.value; + clients[clientIndex].onSelect(); + if (seed != null) { + phraseChanged(); + } + else { + rootKeyChanged(); + } + } function setEntropyVisibility() { if (isUsingOwnEntropy()) { @@ -512,14 +529,28 @@ } function displayAddresses(start, total) { - for (var i=0; i 0) { + var generation = generationProcesses.shift(); + generation.stop(); + } } function clearKey() { @@ -647,8 +689,9 @@ var closestWord = words[0]; for (var i=0; i"); + option.attr("value", i); + option.text(client.name); + DOM.phraseClient.append(option); + } + } function getLanguage() { var defaultLanguage = "english"; @@ -815,7 +868,7 @@ var hash = sjcl.hash.sha256.hash(entropy.cleanStr); var hex = sjcl.codec.hex.fromBits(hash); bits = BigInteger.parse(hex, 16).toString(2); - for (var i=0; i<256-bits.length; i++) { + while (bits.length % 256 != 0) { bits = "0" + bits; } // Truncate hash to suit number of words @@ -1096,6 +1149,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();