]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - src/js/index.js
Pad eth private keys correctly
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / index.js
index fd8c16b99173bcb4a8a6a3c49793bf062dd63d4e..c502208d3b468737c3cc1f86d059434e5ba9de1d 100644 (file)
                     address = libs.ethUtil.addHexPrefix(checksumAddress);
                     pubkey = libs.ethUtil.addHexPrefix(pubkey);
                     if (hasPrivkey) {
-                        privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer());
+                        privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer(32));
                     }
                 }
                 //TRX is different
                          address = libs.bchaddrSlp.toSlpAddress(address);
                      }
                  }
+
+                // ZooBC address format may vary
+                if (networks[DOM.network.val()].name == "ZBC - ZooBlockchain") {  
+                    
+                    var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
+                    var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
+                    var path = "m/";
+                        path += purpose + "'/";
+                        path += coin + "'/" + index + "'";
+                    var result = libs.zoobcUtil.getKeypair(path, seed);
+    
+                    let publicKey = result.pubKey.slice(1, 33);
+                    let privateKey = result.key;
+    
+                    privkey = privateKey.toString('hex');
+                    pubkey = publicKey.toString('hex');
+    
+                    indexText = path;
+                    address = libs.zoobcUtil.getZBCAddress(publicKey, 'ZBC');
+                }
+
                 // Segwit addresses are different
                 if (isSegwit) {
                     if (!segwitAvailable) {
                     privkey = FIObufferToPrivate(keyPair.d.toBuffer(32));
                 }
 
+                if (networks[DOM.network.val()].name == "ATOM - Cosmos Hub") {
+                    address = CosmosBufferToAddress(keyPair.getPublicKeyBuffer());
+                    pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer());
+                    privkey = keyPair.d.toBuffer().toString("base64");
+                }
+
                 //Groestlcoin Addresses are different
                 if(isGRS()) {
 
                 setHdCoin(357);
             },
         },
+        {
+            name: "ATOM - Cosmos Hub",
+            onSelect: function() {
+                network = libs.bitcoin.networks.bitcoin;
+                setHdCoin(118);
+            },
+        },
         {
             name: "AUR - Auroracoin",
             onSelect: function() {
                 setHdCoin(4);
             },
         },
+        {
+            name: "RITO - Ritocoin",
+            onSelect: function() {
+                network = libs.bitcoin.networks.ritocoin;
+                setHdCoin(19169);
+            },
+        },
         {
             name: "RVR - RevolutionVR",
             onSelect: function() {
                 setHdCoin(136);
             },
         },
+        {
+            name: "ZBC - ZooBlockchain",
+            onSelect: function () {
+            network = libs.bitcoin.networks.zoobc;
+            setHdCoin(883);
+            },
+        },
         {
             name: "ZCL - Zclassic",
             onSelect: function() {