diff options
author | Panagiotis David <panagiotis@coinomi.com> | 2019-06-06 21:45:57 +0300 |
---|---|---|
committer | Panagiotis David <onnateldome@gmail.com> | 2019-06-10 10:53:30 +0300 |
commit | b85da0745a0bcf438c2ef19b72dd44d1b09ccd94 (patch) | |
tree | c9630b8cf78e816448f1ad229945b743714afb3e | |
parent | 22bb112ead9e32d1761cd80aba65ade61864cd6c (diff) | |
download | BIP39-b85da0745a0bcf438c2ef19b72dd44d1b09ccd94.tar.gz BIP39-b85da0745a0bcf438c2ef19b72dd44d1b09ccd94.tar.zst BIP39-b85da0745a0bcf438c2ef19b72dd44d1b09ccd94.zip |
ADD support MONK, LTCt, DOGEt
-rw-r--r-- | src/js/bitcoinjs-extensions.js | 37 | ||||
-rw-r--r-- | src/js/index.js | 26 | ||||
-rw-r--r-- | tests/spec/tests.js | 23 |
3 files changed, 81 insertions, 5 deletions
diff --git a/src/js/bitcoinjs-extensions.js b/src/js/bitcoinjs-extensions.js index 16e9385..f7e708b 100644 --- a/src/js/bitcoinjs-extensions.js +++ b/src/js/bitcoinjs-extensions.js | |||
@@ -47,14 +47,14 @@ bitcoinjs.bitcoin.networks.crown = { | |||
47 | 47 | ||
48 | var addrBytes = b58.decode(oldAddress); | 48 | var addrBytes = b58.decode(oldAddress); |
49 | 49 | ||
50 | var hash160 = new Uint16Array(23); | 50 | var hash160 = new Uint16Array(23); |
51 | hash160[0]= 0x01; //C | 51 | hash160[0]= 0x01; //C |
52 | hash160[1]= 0x75; //R | 52 | hash160[1]= 0x75; //R |
53 | hash160[2]= 0x07; //W | 53 | hash160[2]= 0x07; //W |
54 | addrBytes.copy(hash160, 3, 1, 21); | 54 | addrBytes.copy(hash160, 3, 1, 21); |
55 | 55 | ||
56 | var checksum = bitcoinjs.bitcoin.crypto.hash256(hash160).subarray(0, 4); | 56 | var checksum = bitcoinjs.bitcoin.crypto.hash256(hash160).subarray(0, 4); |
57 | var binaryAddr = new Uint16Array(27); | 57 | var binaryAddr = new Uint16Array(27); |
58 | binaryAddr.set(hash160,0); | 58 | binaryAddr.set(hash160,0); |
59 | checksum.copy(binaryAddr, 23, 0, 4); | 59 | checksum.copy(binaryAddr, 23, 0, 4); |
60 | var newAddress = b58.encode(binaryAddr); | 60 | var newAddress = b58.encode(binaryAddr); |
@@ -172,6 +172,17 @@ bitcoinjs.bitcoin.networks.dogecoin = { | |||
172 | wif: 0x9e | 172 | wif: 0x9e |
173 | }; | 173 | }; |
174 | 174 | ||
175 | bitcoinjs.bitcoin.networks.dogecointestnet = { | ||
176 | messagePrefix: '\x19Dogecoin Signed Message:\n', | ||
177 | bip32: { | ||
178 | public: 0x043587cf, | ||
179 | private: 0x04358394 | ||
180 | }, | ||
181 | pubKeyHash: 0x71, | ||
182 | scriptHash: 0xc4, | ||
183 | wif: 0xf1 | ||
184 | }; | ||
185 | |||
175 | bitcoinjs.bitcoin.networks.denarius = { | 186 | bitcoinjs.bitcoin.networks.denarius = { |
176 | messagePrefix: '\x19Denarius Signed Message:\n', | 187 | messagePrefix: '\x19Denarius Signed Message:\n', |
177 | bip32: { | 188 | bip32: { |
@@ -878,6 +889,17 @@ bitcoinjs.bitcoin.networks.linx = { | |||
878 | wif: 0xcb, | 889 | wif: 0xcb, |
879 | }; | 890 | }; |
880 | 891 | ||
892 | |||
893 | bitcoinjs.bitcoin.networks.litecointestnet = { | ||
894 | messagePrefix: '\x18Litecoin Signed Message:\n', | ||
895 | bip32: { | ||
896 | public: 0x043587cf, | ||
897 | private: 0x04358394, | ||
898 | }, | ||
899 | pubKeyHash: 0x6f, | ||
900 | scriptHash: 0xc4, | ||
901 | wif: 0xef, | ||
902 | }; | ||
881 | bitcoinjs.bitcoin.networks.litecoincash = { | 903 | bitcoinjs.bitcoin.networks.litecoincash = { |
882 | messagePrefix: '\x18Litecoin Signed Message:\n', | 904 | messagePrefix: '\x18Litecoin Signed Message:\n', |
883 | bip32: { | 905 | bip32: { |
@@ -1549,3 +1571,14 @@ bitcoinjs.bitcoin.networks.deeponion = { | |||
1549 | scriptHash: 0x4E, | 1571 | scriptHash: 0x4E, |
1550 | wif: 0x9F, | 1572 | wif: 0x9F, |
1551 | }; | 1573 | }; |
1574 | |||
1575 | bitcoinjs.bitcoin.networks.monkey = { | ||
1576 | messagePrefix: 'x18DarkNet Signed Message:\n', | ||
1577 | bip32: { | ||
1578 | public: 0x0488B21E, | ||
1579 | private: 0x0488ADE4, | ||
1580 | }, | ||
1581 | pubKeyHash: 0x7F, | ||
1582 | scriptHash: 0xC4, | ||
1583 | wif: 0x3F, | ||
1584 | }; | ||
diff --git a/src/js/index.js b/src/js/index.js index 88b1e09..7e65434 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -980,11 +980,11 @@ | |||
980 | address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network) | 980 | address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network) |
981 | } | 981 | } |
982 | } | 982 | } |
983 | 983 | ||
984 | if ((networks[DOM.network.val()].name == "CRW - Crown")) { | 984 | if ((networks[DOM.network.val()].name == "CRW - Crown")) { |
985 | address = bitcoinjs.bitcoin.networks.crown.toNewAddress(address); | 985 | address = bitcoinjs.bitcoin.networks.crown.toNewAddress(address); |
986 | } | 986 | } |
987 | 987 | ||
988 | addAddressToList(indexText, address, pubkey, privkey); | 988 | addAddressToList(indexText, address, pubkey, privkey); |
989 | if (isLast) { | 989 | if (isLast) { |
990 | hidePending(); | 990 | hidePending(); |
@@ -1960,6 +1960,13 @@ | |||
1960 | }, | 1960 | }, |
1961 | }, | 1961 | }, |
1962 | { | 1962 | { |
1963 | name: "DOGEt - Dogecoin Testnet", | ||
1964 | onSelect: function() { | ||
1965 | network = bitcoinjs.bitcoin.networks.dogecointestnet; | ||
1966 | setHdCoin(1); | ||
1967 | }, | ||
1968 | }, | ||
1969 | { | ||
1963 | name: "DXN - DEXON", | 1970 | name: "DXN - DEXON", |
1964 | onSelect: function() { | 1971 | onSelect: function() { |
1965 | network = bitcoinjs.bitcoin.networks.bitcoin; | 1972 | network = bitcoinjs.bitcoin.networks.bitcoin; |
@@ -2213,6 +2220,14 @@ | |||
2213 | }, | 2220 | }, |
2214 | }, | 2221 | }, |
2215 | { | 2222 | { |
2223 | name: "LTCt - Litecoin Testnet", | ||
2224 | onSelect: function() { | ||
2225 | network = bitcoinjs.bitcoin.networks.litecointestnet; | ||
2226 | setHdCoin(1); | ||
2227 | DOM.litecoinLtubContainer.removeClass("hidden"); | ||
2228 | }, | ||
2229 | }, | ||
2230 | { | ||
2216 | name: "LTZ - LitecoinZ", | 2231 | name: "LTZ - LitecoinZ", |
2217 | onSelect: function() { | 2232 | onSelect: function() { |
2218 | network = bitcoinjs.bitcoin.networks.litecoinz; | 2233 | network = bitcoinjs.bitcoin.networks.litecoinz; |
@@ -2756,6 +2771,13 @@ | |||
2756 | setHdCoin(121); | 2771 | setHdCoin(121); |
2757 | }, | 2772 | }, |
2758 | }, | 2773 | }, |
2774 | { | ||
2775 | name: "MONK - Monkey Project", | ||
2776 | ` onSelect: function() { | ||
2777 | network = bitcoinjs.bitcoin.networks.monkey; | ||
2778 | setHdCoin(214); | ||
2779 | }, | ||
2780 | } | ||
2759 | ] | 2781 | ] |
2760 | 2782 | ||
2761 | var clients = [ | 2783 | var clients = [ |
diff --git a/tests/spec/tests.js b/tests/spec/tests.js index e3f7e1c..d609dca 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js | |||
@@ -408,6 +408,13 @@ it('Allows selection of litecoin', function(done) { | |||
408 | }; | 408 | }; |
409 | testNetwork(done, params); | 409 | testNetwork(done, params); |
410 | }); | 410 | }); |
411 | it('Allows selection of litecoin testnet', function(done) { | ||
412 | var params = { | ||
413 | selectText: "LTCt - Litecoin Testnet", | ||
414 | firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi", | ||
415 | }; | ||
416 | testNetwork(done, params); | ||
417 | }); | ||
411 | it('Allows selection of ripple', function(done) { | 418 | it('Allows selection of ripple', function(done) { |
412 | var params = { | 419 | var params = { |
413 | selectText: "XRP - Ripple", | 420 | selectText: "XRP - Ripple", |
@@ -423,6 +430,13 @@ it('Allows selection of dogecoin', function(done) { | |||
423 | }; | 430 | }; |
424 | testNetwork(done, params); | 431 | testNetwork(done, params); |
425 | }); | 432 | }); |
433 | it('Allows selection of dogecoin testnet', function(done) { | ||
434 | var params = { | ||
435 | selectText: "DOGEt - Dogecoin testnet", | ||
436 | firstAddress: "niHnSJKHdwDyDxRMLBJrtNqpvHEsAFWe6B", | ||
437 | }; | ||
438 | testNetwork(done, params); | ||
439 | }); | ||
426 | it('Allows selection of denarius', function(done) { | 440 | it('Allows selection of denarius', function(done) { |
427 | var params = { | 441 | var params = { |
428 | selectText: "DNR - Denarius", | 442 | selectText: "DNR - Denarius", |
@@ -475,7 +489,7 @@ it('Allows selection of clam', function(done) { | |||
475 | it('Allows selection of crown', function(done) { | 489 | it('Allows selection of crown', function(done) { |
476 | var params = { | 490 | var params = { |
477 | selectText: "CRW - Crown (Legacy)", | 491 | selectText: "CRW - Crown (Legacy)", |
478 | firstAddress: "18pWSwSUAQdiwMHUfFZB1fM2xue9X1FqE5", | 492 | firstAddress: "18pWSwSUAQdiwMHUfFZB1fM2xue9X1FqE5", |
479 | }; | 493 | }; |
480 | testNetwork(done, params); | 494 | testNetwork(done, params); |
481 | }); | 495 | }); |
@@ -1462,6 +1476,13 @@ it('Allows selection of Ethersocial Network', function(done) { | |||
1462 | }; | 1476 | }; |
1463 | testNetwork(done, params); | 1477 | testNetwork(done, params); |
1464 | }); | 1478 | }); |
1479 | it('Allows selection of Monkey Project', function(done) { | ||
1480 | var params = { | ||
1481 | selectText: "MONK - Monkey Project", | ||
1482 | firstAddress: "MnLrcnnUzKnf7TzufjRe5DLZqQJz18oYyu", | ||
1483 | }; | ||
1484 | testNetwork(done, params); | ||
1485 | }); | ||
1465 | 1486 | ||
1466 | // BIP39 seed is set from phrase | 1487 | // BIP39 seed is set from phrase |
1467 | it('Sets the bip39 seed from the prhase', function(done) { | 1488 | it('Sets the bip39 seed from the prhase', function(done) { |