X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Findex.js;h=c3c0a4aae4da5bddedde6543a668659a8516139a;hb=3f363a42b15c7fd7338b0ad35d7a32fb96621aee;hp=45edea8477b835245c3a03b34183310f226ebbc3;hpb=ba3cb9ecae2667e98af71f5b38a862ba604e8e1c;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/index.js b/src/js/index.js index 45edea8..c3c0a4a 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -3,7 +3,7 @@ // mnemonics is populated as required by getLanguage var mnemonics = { "english": new Mnemonic("english") }; var mnemonic = mnemonics["english"]; - var seed = null + var seed = null; var bip32RootKey = null; var bip32ExtendedKey = null; var network = bitcoin.networks.bitcoin; @@ -19,6 +19,8 @@ var phraseChangeTimeoutEvent = null; var rootKeyChangedTimeoutEvent = null; + var generationProcesses = []; + var DOM = {}; DOM.network = $(".network"); DOM.phraseNetwork = $("#network-phrase"); @@ -324,6 +326,10 @@ } function calcBip32ExtendedKey(path) { + // Check there's a root key to derive from + if (!bip32RootKey) { + return bip32RootKey; + } var extendedKey = bip32RootKey; // Derive the key from the path var pathBits = path.split("/"); @@ -458,6 +464,10 @@ } } } + // Check root key exists or else derivation path is useless! + if (!bip32RootKey) { + return "No root key"; + } // Check no hardened derivation path when using xpub keys var hardened = path.indexOf("'") > -1; var isXpubkey = !("privKey" in bip32RootKey); @@ -504,14 +514,28 @@ } function displayAddresses(start, total) { - for (var i=0; i 0) { + var generation = generationProcesses.shift(); + generation.stop(); + } } function clearKey() { @@ -639,6 +674,9 @@ var closestWord = words[0]; for (var i=0; i