X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Findex.js;h=4f1ab249f3732fb9ae66f7cdc7b0e7d5360a60b7;hb=3e0ed16a93761d6b706ddcc10ee37319fec43e36;hp=2f7815d540b9b2fc48f724561a20319e11d6ba1f;hpb=ae30fed8037fa9d1e88e9431c4f301f1d1c53d29;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/index.js b/src/js/index.js index 2f7815d..4f1ab24 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1,6 +1,7 @@ (function() { var mnemonic = new Mnemonic("english"); + var seed = null var bip32RootKey = null; var bip32ExtendedKey = null; var network = bitcoin.networks.bitcoin; @@ -18,6 +19,7 @@ DOM.phrase = $(".phrase"); DOM.passphrase = $(".passphrase"); DOM.generate = $(".generate"); + DOM.seed = $(".seed"); DOM.rootKey = $(".root-key"); DOM.extendedPrivKey = $(".extended-priv-key"); DOM.extendedPubKey = $(".extended-pub-key"); @@ -135,7 +137,6 @@ function bip44Changed() { setBip44DerivationPath(); - derivationPath = DOM.bip44path.val(); derivationChanged(); } @@ -163,21 +164,6 @@ return; } var numWords = parseInt(DOM.strength.val()); - // Check strength is an integer - if (isNaN(numWords)) { - DOM.strength.val("12"); - numWords = 12; - } - // Check strength is a multiple of 32, if not round it down - if (numWords % 3 != 0) { - numWords = Math.floor(numWords / 3) * 3; - DOM.strength.val(numWords); - } - // Check strength is at least 32 - if (numWords == 0) { - numWords = 3; - DOM.strength.val(numWords); - } var strength = numWords / 3 * 32; var words = mnemonic.generate(strength); DOM.phrase.val(words); @@ -185,7 +171,7 @@ } function calcBip32Seed(phrase, passphrase, path) { - var seed = mnemonic.toSeed(phrase, passphrase); + seed = mnemonic.toSeed(phrase, passphrase); bip32RootKey = bitcoin.HDNode.fromSeedHex(seed, network); bip32ExtendedKey = bip32RootKey; // Derive the key from the path @@ -248,6 +234,7 @@ function displayBip32Info() { // Display the key + DOM.seed.val(seed); var rootKey = bip32RootKey.toBase58(); DOM.rootKey.val(rootKey); var extendedPrivKey = bip32ExtendedKey.toBase58(); @@ -337,7 +324,7 @@ addressCell.addClass("invisible"); } if (!showPrivKey) { - privkeCell.addClass("invisible"); + privkeyCell.addClass("invisible"); } DOM.addresses.append(row); } @@ -363,6 +350,7 @@ path += account + "'/"; path += change; DOM.bip44path.val(path); + derivationPath = DOM.bip44path.val(); } function parseIntNoNaN(val, defaultVal) { @@ -459,6 +447,13 @@ DOM.bip44coin.val(26); }, }, + { + name: "CLAM", + onSelect: function() { + network = bitcoin.networks.clam; + DOM.bip44coin.val(23); + }, + }, ] init();