]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Add TRX coin support
authorzr <zr@coinhub.dev>
Thu, 10 Sep 2020 09:40:56 +0000 (17:40 +0800)
committerzr <zr@coinhub.dev>
Thu, 10 Sep 2020 09:40:56 +0000 (17:40 +0800)
src/js/index.js

index 252eec1ced72cca6fb04ba09a80898b9713f021c..2c02721d5ac75b9f61f1bf67295db04e2a902cef 100644 (file)
                         privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer());
                     }
                 }
+                //TRX is different
+                if (networks[DOM.network.val()].name == "TRX - Tron") {
+                    var pubkeyBuffer = keyPair.getPublicKeyBuffer();
+                    var ethPubkey = libs.ethUtil.importPublic(pubkeyBuffer);
+                    var addressBuffer = libs.ethUtil.publicToAddress(ethPubkey);
+                    address = libs.bitcoin.address.toBase58Check(addressBuffer, 0x41);
+                    if (hasPrivkey) {
+                        privkey = keyPair.d.toBuffer().toString('hex');
+                    }
+                }
 
                 // RSK values are different
                 if (networkIsRsk()) {
                 setHdCoin(159);
             },
         },
+        {
+            name: "TRX - Tron",
+            onSelect: function() {
+                setHdCoin(195);
+            },
+        },
         {
             name: "TWINS - TWINS",
             onSelect: function() {