]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - bip39-standalone.html
Merge pull request #20 from dooglus/ignore_space_changes
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / bip39-standalone.html
index 9a402528d5221f1bc0f975f6b648a2eb11ac6436..370a5ff73ad5a76ed5af0bfd1511d5d6db612f42 100644 (file)
                             <label for="strength" class="col-sm-2 control-label">Number of words</label>
                             <div class="col-sm-10">
                                 <div class="input-group">
-                                    <input type="number" class="strength form-control" id="strength" value="12">
+                                    <select id="strength" class="strength form-control">
+                                        <option val="3">3</option>
+                                        <option val="6">6</option>
+                                        <option val="9">9</option>
+                                        <option val="12">12</option>
+                                        <option val="15" selected>15</option>
+                                        <option val="18">18</option>
+                                        <option val="21">21</option>
+                                        <option val="24">24</option>
+                                    </select>
                                     <span class="input-group-btn">
                                         <button class="btn generate">Generate Random Mnemonic</button>
                                     </span>
@@ -13101,6 +13110,15 @@ bitcoin.networks.shadowtn = {
   feePerKb: 1000,
   estimateFee: function() { return "unused in this app" },
 };
+
+bitcoin.networks.clam = {
+  bip32: {
+    public: 0xa8c26d64,
+    private: 0xa8c17826
+  },
+  pubKeyHash: 0x89,
+  wif: 0x85,
+};
 </script>
         <script>// Select components from sjcl to suit the crypto operations bip39 requires.
 
@@ -14502,7 +14520,7 @@ var Mnemonic = function(language) {
 
     self.toSeed = function(mnemonic, passphrase) {
         passphrase = passphrase || '';
-        mnemonic = self.normalizeString(mnemonic)
+        mnemonic = self.normalizeString(mnemonic).split(' ').filter(function(x) { return x.length; }).join(' ');
         passphrase = self.normalizeString(passphrase)
         passphrase = "mnemonic" + passphrase;
         var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
@@ -14744,21 +14762,6 @@ var Mnemonic = function(language) {
             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);
@@ -14918,7 +14921,7 @@ var Mnemonic = function(language) {
             addressCell.addClass("invisible");
         }
         if (!showPrivKey) {
-            privkeCell.addClass("invisible");
+            privkeyCell.addClass("invisible");
         }
         DOM.addresses.append(row);
     }
@@ -15041,6 +15044,13 @@ var Mnemonic = function(language) {
                 DOM.bip44coin.val(26);
             },
         },
+        {
+            name: "CLAM",
+            onSelect: function() {
+                network = bitcoin.networks.clam;
+                DOM.bip44coin.val(23);
+            },
+        },
     ]
 
     init();