]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - bip39-standalone.html
update root key network
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / bip39-standalone.html
index 9d0de5ed924b76f9a1ef1f11ffd5f634270b762a..9b3c4f18f8e78e90ec9a4ba1787d004a0481d6f5 100644 (file)
                             <div class="col-sm-10">
                                 <div class="input-group">
                                     <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>
+                                        <option value="3">3</option>
+                                        <option value="6">6</option>
+                                        <option value="9">9</option>
+                                        <option value="12">12</option>
+                                        <option value="15" selected>15</option>
+                                        <option value="18">18</option>
+                                        <option value="21">21</option>
+                                        <option value="24">24</option>
                                     </select>
                                     <span class="input-group-btn">
                                         <button class="btn generate">Generate Random Mnemonic</button>
                                         <input id="bip32-path" type="text" class="path form-control" value="m/0">
                                     </div>
                                 </div>
+                                <div class="form-group">
+                                    <div class="col-sm-2"></div>
+                                    <label class="col-sm-10">
+                                        <input class="hardened-addresses" type="checkbox">
+                                        Use hardened addresses
+                                    </label>
+                                </div>
                                 <div class="form-group">
                                     <label class="col-sm-2 control-label">Hive Wallet</label>
                                     <div class="col-sm-10">
                                         </p>
                                     </div>
                                 </div>
+                                <div class="form-group">
+                                    <label for="core-path" class="col-sm-2 control-label">Bitcoin Core</label>
+                                    <div class="col-sm-10">
+                                        <p class="form-control no-border">
+                                        Use path <code>m/0'/0'</code> with hardened addresses.
+                                        For more info see the <a href="https://github.com/bitcoin/bitcoin/pull/8035" target="_blank">Bitcoin Core BIP32 implementation</a>
+                                        </p>
+                                    </div>
+                                </div>
                             </form>
                         </div>
                     </div>
@@ -13337,6 +13353,17 @@ bitcoin.networks.clam = {
   pubKeyHash: 0x89,
   wif: 0x85,
 };
+
+bitcoin.networks.dash = {
+  bip32: {
+    public: 0x0488b21e,
+    private: 0x0488ade4
+  },
+  pubKeyHash: 0x4c,
+  scriptHash: 0x10,
+  wif: 0xcc,
+};
+
 </script>
         <script>// Select components from sjcl to suit the crypto operations bip39 requires.
 
@@ -14853,6 +14880,7 @@ var Mnemonic = function(language) {
     DOM.bip44account = $("#bip44 .account");
     DOM.bip44change = $("#bip44 .change");
     DOM.strength = $(".strength");
+    DOM.hardenedAddresses = $(".hardened-addresses");
     DOM.addresses = $(".addresses");
     DOM.rowsToAdd = $(".rows-to-add");
     DOM.more = $(".more");
@@ -14876,6 +14904,7 @@ var Mnemonic = function(language) {
         DOM.bip44account.on("input", calcForDerivationPath);
         DOM.bip44change.on("input", calcForDerivationPath);
         DOM.tab.on("shown.bs.tab", calcForDerivationPath);
+        DOM.hardenedAddresses.on("change", calcForDerivationPath);
         DOM.indexToggle.on("click", toggleIndexes);
         DOM.addressToggle.on("click", toggleAddresses);
         DOM.privateKeyToggle.on("click", togglePrivateKeys);
@@ -14888,9 +14917,14 @@ var Mnemonic = function(language) {
     // Event handlers
 
     function networkChanged(e) {
-        var network = e.target.value;
-        networks[network].onSelect();
-        displayBip32Info();
+        var networkIndex = e.target.value;
+        networks[networkIndex].onSelect();
+        if (seed != null) {
+            phraseChanged();
+        }
+        else {
+            rootKeyChanged();
+        }
     }
 
     function delayedPhraseChanged() {
@@ -15018,7 +15052,7 @@ var Mnemonic = function(language) {
     }
 
     function calcBip32RootKeyFromBase58(rootKeyBase58) {
-        bip32RootKey = bitcoin.HDNode.fromBase58(rootKeyBase58);
+        bip32RootKey = bitcoin.HDNode.fromBase58(rootKeyBase58, network);
     }
 
     function calcBip32ExtendedKey(path) {
@@ -15180,16 +15214,27 @@ var Mnemonic = function(language) {
 
     function TableRow(index) {
 
+        var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
+
         function init() {
             calculateValues();
         }
 
         function calculateValues() {
             setTimeout(function() {
-                var key = bip32ExtendedKey.derive(index);
+                var key = "";
+                if (useHardenedAddresses) {
+                    key = bip32ExtendedKey.deriveHardened(index);
+                }
+                else {
+                    key = bip32ExtendedKey.derive(index);
+                }
                 var address = key.getAddress().toString();
                 var privkey = key.privKey.toWIF(network);
                 var indexText = getDerivationPath() + "/" + index;
+                if (useHardenedAddresses) {
+                    indexText = indexText + "'";
+                }
                 addAddressToList(indexText, address, privkey);
             }, 50)
         }
@@ -15380,6 +15425,13 @@ var Mnemonic = function(language) {
                 DOM.bip44coin.val(23);
             },
         },
+        {
+            name: "DASH",
+            onSelect: function() {
+                network = bitcoin.networks.dash;
+                DOM.bip44coin.val(5);
+            },
+        },
     ]
 
     init();