From b674c5710b70c9dac9f11758cac222d45575dec2 Mon Sep 17 00:00:00 2001 From: zr Date: Thu, 10 Sep 2020 17:40:56 +0800 Subject: Add TRX coin support --- src/js/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/js/index.js b/src/js/index.js index 252eec1..2c02721 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1139,6 +1139,16 @@ 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()) { @@ -3228,6 +3238,12 @@ setHdCoin(159); }, }, + { + name: "TRX - Tron", + onSelect: function() { + setHdCoin(195); + }, + }, { name: "TWINS - TWINS", onSelect: function() { -- cgit v1.2.3 From d7125cda1d60199016272c34b2ce740f06077293 Mon Sep 17 00:00:00 2001 From: zr Date: Fri, 18 Sep 2020 15:28:56 +0800 Subject: Modify to use uncompressed public key as keccak256 input for TRX --- src/js/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/index.js b/src/js/index.js index 2c02721..e959c58 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1141,6 +1141,7 @@ } //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); -- cgit v1.2.3 From 47dbf58b6d499230eb07f7ea126af6b367e9039b Mon Sep 17 00:00:00 2001 From: zr Date: Mon, 5 Oct 2020 12:04:14 +0800 Subject: Add testcase for TRX --- tests/spec/tests.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 14cdb8e..d73f17d 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -2276,6 +2276,17 @@ it('Allows selection of Scribe', 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')) -- cgit v1.2.3