aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/combined/index.js33
-rw-r--r--src/js/bitcoinjs-extensions.js23
-rw-r--r--src/js/index.js35
-rw-r--r--tests/spec/tests.js21
4 files changed, 112 insertions, 0 deletions
diff --git a/libs/combined/index.js b/libs/combined/index.js
index 99af3ce..d3bc7a5 100644
--- a/libs/combined/index.js
+++ b/libs/combined/index.js
@@ -2,6 +2,10 @@
2 2
3module.exports.basex = require('base-x') 3module.exports.basex = require('base-x')
4 4
5/* base32 */
6
7module.exports.base32 = require('base32.js')
8
5/* bchaddrjs */ 9/* bchaddrjs */
6 10
7module.exports.bchaddr = require('bchaddrjs') 11module.exports.bchaddr = require('bchaddrjs')
@@ -84,6 +88,35 @@ module.exports.stellarUtil = {
84 }, 88 },
85} 89}
86 90
91/* zoobc-util */
92
93let base32 = require('base32.js');
94let nbl = require('nebulas');
95module.exports.zoobcUtil = {
96 getKeypair: function (path, seed) {
97 const { key, chainCode} = edHd.derivePath(path, seed);
98 const pubKey = edHd.getPublicKey(key);
99 return {key,chainCode, pubKey};
100 },
101 getZBCAddress(publicKey, prefix = "ZBC") {
102 const prefixDefault = ["ZBC", "ZNK", "ZBL", "ZTX"];
103 const valid = prefixDefault.indexOf(prefix) > -1;
104 if (valid) {
105 var bytes = new Uint8Array(35);
106 for (let i = 0; i < 32; i++) bytes[i] = publicKey[i];
107 for (let i = 0; i < 3; i++) bytes[i + 32] = prefix.charCodeAt(i);
108 const checksum = nbl.CryptoUtils.sha3(bytes);
109 for (let i = 0; i < 3; i++) bytes[i + 32] = Number(checksum[i]);
110 var segs = [prefix];
111 var b32 = base32.encode(bytes);
112 for (let i = 0; i < 7; i++) segs.push(b32.substr(i * 8, 8));
113 return segs.join("_");
114 } else {
115 throw new Error("The Prefix not available!");
116 }
117 }
118}
119
87/* nano-util */ 120/* nano-util */
88 121
89let NanoBase = require('nanocurrency-web'); 122let NanoBase = require('nanocurrency-web');
diff --git a/src/js/bitcoinjs-extensions.js b/src/js/bitcoinjs-extensions.js
index b049d78..84de8da 100644
--- a/src/js/bitcoinjs-extensions.js
+++ b/src/js/bitcoinjs-extensions.js
@@ -1219,6 +1219,17 @@ libs.bitcoin.networks.revolutionvr = {
1219 wif: 0xc6, 1219 wif: 0xc6,
1220}; 1220};
1221 1221
1222libs.bitcoin.networks.ritocoin = {
1223 messagePrefix: '\x15Rito Signed Message:\n',
1224 bip32: {
1225 public: 0x0488B21E,
1226 private: 0x0488ADE4,
1227 },
1228 pubKeyHash: 0x19,
1229 scriptHash: 0x69,
1230 wif: 0x8b,
1231};
1232
1222libs.bitcoin.networks.rsk = { 1233libs.bitcoin.networks.rsk = {
1223 messagePrefix: '\x18RSK Signed Message:\n', 1234 messagePrefix: '\x18RSK Signed Message:\n',
1224 bip32: { 1235 bip32: {
@@ -1553,6 +1564,18 @@ libs.bitcoin.networks.hush3 = {
1553 wif: 0xBC, 1564 wif: 0xBC,
1554}; 1565};
1555 1566
1567libs.bitcoin.networks.zoobc = {
1568 messagePrefix: '\x18ZooBC Signed Message:\n',
1569 bech32: 'bc',
1570 bip32: {
1571 public: 0x0488b21e,
1572 private: 0x0488ade4,
1573 },
1574 pubKeyHash: 0x00,
1575 scriptHash: 0x05,
1576 wif: 0x80,
1577};
1578
1556libs.bitcoin.networks.zclassic = { 1579libs.bitcoin.networks.zclassic = {
1557 messagePrefix: '\x18Zcash Signed Message:\n', 1580 messagePrefix: '\x18Zcash Signed Message:\n',
1558 bip32: { 1581 bip32: {
diff --git a/src/js/index.js b/src/js/index.js
index fd8c16b..713b5e8 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -1348,6 +1348,27 @@
1348 address = libs.bchaddrSlp.toSlpAddress(address); 1348 address = libs.bchaddrSlp.toSlpAddress(address);
1349 } 1349 }
1350 } 1350 }
1351
1352 // ZooBC address format may vary
1353 if (networks[DOM.network.val()].name == "ZBC - ZooBlockchain") {
1354
1355 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
1356 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
1357 var path = "m/";
1358 path += purpose + "'/";
1359 path += coin + "'/" + index + "'";
1360 var result = libs.zoobcUtil.getKeypair(path, seed);
1361
1362 let publicKey = result.pubKey.slice(1, 33);
1363 let privateKey = result.key;
1364
1365 privkey = privateKey.toString('hex');
1366 pubkey = publicKey.toString('hex');
1367
1368 indexText = path;
1369 address = libs.zoobcUtil.getZBCAddress(publicKey, 'ZBC');
1370 }
1371
1351 // Segwit addresses are different 1372 // Segwit addresses are different
1352 if (isSegwit) { 1373 if (isSegwit) {
1353 if (!segwitAvailable) { 1374 if (!segwitAvailable) {
@@ -3219,6 +3240,13 @@
3219 }, 3240 },
3220 }, 3241 },
3221 { 3242 {
3243 name: "RITO - Ritocoin",
3244 onSelect: function() {
3245 network = libs.bitcoin.networks.ritocoin;
3246 setHdCoin(19169);
3247 },
3248 },
3249 {
3222 name: "RVR - RevolutionVR", 3250 name: "RVR - RevolutionVR",
3223 onSelect: function() { 3251 onSelect: function() {
3224 network = libs.bitcoin.networks.revolutionvr; 3252 network = libs.bitcoin.networks.revolutionvr;
@@ -3541,6 +3569,13 @@
3541 }, 3569 },
3542 }, 3570 },
3543 { 3571 {
3572 name: "ZBC - ZooBlockchain",
3573 onSelect: function () {
3574 network = libs.bitcoin.networks.zoobc;
3575 setHdCoin(883);
3576 },
3577 },
3578 {
3544 name: "ZCL - Zclassic", 3579 name: "ZCL - Zclassic",
3545 onSelect: function() { 3580 onSelect: function() {
3546 network = libs.bitcoin.networks.zclassic; 3581 network = libs.bitcoin.networks.zclassic;
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index 0332f96..f350fa7 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -1635,6 +1635,16 @@ it('Allows selection of RevolutionVR', function(done) {
1635 }; 1635 };
1636 testNetwork(done, params); 1636 testNetwork(done, params);
1637}); 1637});
1638it('Allows selection of Ritocoin', function(done) {
1639 var params = {
1640 selectText: "RITO - Ritocoin",
1641 phrase: "abandon abandon ability",
1642 firstAddress: "BMbHdwDiuaZh4ATp8Xapf4srv3swzAGgkf",
1643 firstPubKey: "036f5f55dc37fa97294a2a5ae4d92735d4392d4405cbbebebf2d70d5d6781be622",
1644 firstPrivKey: "L1CyVD5ADNgSUxZn6kRpJe9e17FDuAZzRGwNjvDBnEqRWjo4SEAX",
1645 };
1646 testNetwork(done, params);
1647});
1638it('Allows selection of Rubycoin', function(done) { 1648it('Allows selection of Rubycoin', function(done) {
1639 var params = { 1649 var params = {
1640 selectText: "RBY - Rubycoin", 1650 selectText: "RBY - Rubycoin",
@@ -2328,6 +2338,17 @@ it('Allows selection of TRX on Tron', function(done) {
2328 testNetwork(done, params); 2338 testNetwork(done, params);
2329}); 2339});
2330 2340
2341it('Allows selection of ZooBlockchain', function(done) {
2342 var params = {
2343 selectText: "ZBC - ZooBlockchain",
2344 phrase: "shy invest oxygen real lunar moral merge corn program air affair amazing dove imitate combine solve library fresh case alcohol pole question act thing",
2345 firstAddress: "ZBC_MGEZVH3U_SXPCBHTU_KSWDPQ4X_K6MSI3VR_CQAYMTLC_RXUMM3DJ_LFABCAXA",
2346 firstPubKey: "61899a9f7495de209e7454ac37c3975799246eb11401864d628de8c66c695940",
2347 firstPrivKey: "adb11e79068fa7366ec4f5963ad57115d666b1ad2b369b92d962563adf7dd48b",
2348 };
2349 testNetwork(done, params);
2350});
2351
2331// BIP39 seed is set from phrase 2352// BIP39 seed is set from phrase
2332it('Sets the bip39 seed from the prhase', function(done) { 2353it('Sets the bip39 seed from the prhase', function(done) {
2333 driver.findElement(By.css('.phrase')) 2354 driver.findElement(By.css('.phrase'))