]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Merge pull request #441 from bytefly/master
authoriancoleman <1281387+iancoleman@users.noreply.github.com>
Sun, 18 Oct 2020 22:12:43 +0000 (09:12 +1100)
committerGitHub <noreply@github.com>
Sun, 18 Oct 2020 22:12:43 +0000 (09:12 +1100)
Add TRX coin support

src/js/index.js
tests/spec/tests.js

index dc2496358c75b8f0bc5f8f8d3b3ead32a4f589b2..114f74ae0e0094d566443fa20b21d81ab1a14e8f 100644 (file)
                         privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer());
                     }
                 }
+                //TRX is different
+                if (networks[DOM.network.val()].name == "TRX - Tron") {
+                    keyPair = new libs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
+                    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() {
index 58318db6df5d9f3f5afca9a139342362bcb1a5e6..8b3b07be1c967bcf9da3e8cff5bc727673c0731f 100644 (file)
@@ -2286,6 +2286,17 @@ it('Allows selection of Binance Smart Chain', function(done) {
     testNetwork(done, params);
 });
 
+it('Allows selection of TRX on Tron', function(done) {
+    var params = {
+        selectText: "TRX - Tron",
+        phrase: "abandon abandon ability",
+        firstAddress: "TA891Fu7vVz595BGQpNX2MCzr7yBcxuoC7",
+        firstPubKey: "0337bbb060e6166066f7f9e59e52f67bc23a6c9d0cbc815b82b6d89112444842e7",
+        firstPrivKey: "3a8fbd0379a815764979de86a3fcda759cb62d49e784e7b2a9a03206c90cfae2",
+    };
+    testNetwork(done, params);
+});
+
 // BIP39 seed is set from phrase
 it('Sets the bip39 seed from the prhase', function(done) {
     driver.findElement(By.css('.phrase'))