diff options
author | iancoleman <1281387+iancoleman@users.noreply.github.com> | 2020-10-19 09:12:43 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 09:12:43 +1100 |
commit | 4669c88c672b0ec2ac636cae96a3fe2db94e2791 (patch) | |
tree | 109e4173462e7f9f9d7afc4cb1fbaa803bcd35eb | |
parent | 9e865b8e757b6ee643027536da9a18b3c0469aa7 (diff) | |
parent | 47dbf58b6d499230eb07f7ea126af6b367e9039b (diff) | |
download | BIP39-4669c88c672b0ec2ac636cae96a3fe2db94e2791.tar.gz BIP39-4669c88c672b0ec2ac636cae96a3fe2db94e2791.tar.zst BIP39-4669c88c672b0ec2ac636cae96a3fe2db94e2791.zip |
Merge pull request #441 from bytefly/master
Add TRX coin support
-rw-r--r-- | src/js/index.js | 17 | ||||
-rw-r--r-- | tests/spec/tests.js | 11 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/js/index.js b/src/js/index.js index dc24963..114f74a 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -1139,6 +1139,17 @@ | |||
1139 | privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer()); | 1139 | privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer()); |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | //TRX is different | ||
1143 | if (networks[DOM.network.val()].name == "TRX - Tron") { | ||
1144 | keyPair = new libs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false }); | ||
1145 | var pubkeyBuffer = keyPair.getPublicKeyBuffer(); | ||
1146 | var ethPubkey = libs.ethUtil.importPublic(pubkeyBuffer); | ||
1147 | var addressBuffer = libs.ethUtil.publicToAddress(ethPubkey); | ||
1148 | address = libs.bitcoin.address.toBase58Check(addressBuffer, 0x41); | ||
1149 | if (hasPrivkey) { | ||
1150 | privkey = keyPair.d.toBuffer().toString('hex'); | ||
1151 | } | ||
1152 | } | ||
1142 | 1153 | ||
1143 | // RSK values are different | 1154 | // RSK values are different |
1144 | if (networkIsRsk()) { | 1155 | if (networkIsRsk()) { |
@@ -3237,6 +3248,12 @@ | |||
3237 | }, | 3248 | }, |
3238 | }, | 3249 | }, |
3239 | { | 3250 | { |
3251 | name: "TRX - Tron", | ||
3252 | onSelect: function() { | ||
3253 | setHdCoin(195); | ||
3254 | }, | ||
3255 | }, | ||
3256 | { | ||
3240 | name: "TWINS - TWINS", | 3257 | name: "TWINS - TWINS", |
3241 | onSelect: function() { | 3258 | onSelect: function() { |
3242 | network = libs.bitcoin.networks.twins; | 3259 | network = libs.bitcoin.networks.twins; |
diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 58318db..8b3b07b 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js | |||
@@ -2286,6 +2286,17 @@ it('Allows selection of Binance Smart Chain', function(done) { | |||
2286 | testNetwork(done, params); | 2286 | testNetwork(done, params); |
2287 | }); | 2287 | }); |
2288 | 2288 | ||
2289 | it('Allows selection of TRX on Tron', function(done) { | ||
2290 | var params = { | ||
2291 | selectText: "TRX - Tron", | ||
2292 | phrase: "abandon abandon ability", | ||
2293 | firstAddress: "TA891Fu7vVz595BGQpNX2MCzr7yBcxuoC7", | ||
2294 | firstPubKey: "0337bbb060e6166066f7f9e59e52f67bc23a6c9d0cbc815b82b6d89112444842e7", | ||
2295 | firstPrivKey: "3a8fbd0379a815764979de86a3fcda759cb62d49e784e7b2a9a03206c90cfae2", | ||
2296 | }; | ||
2297 | testNetwork(done, params); | ||
2298 | }); | ||
2299 | |||
2289 | // BIP39 seed is set from phrase | 2300 | // BIP39 seed is set from phrase |
2290 | it('Sets the bip39 seed from the prhase', function(done) { | 2301 | it('Sets the bip39 seed from the prhase', function(done) { |
2291 | driver.findElement(By.css('.phrase')) | 2302 | driver.findElement(By.css('.phrase')) |