aboutsummaryrefslogtreecommitdiff
path: root/libs/combined/index.js
diff options
context:
space:
mode:
authoriancoleman <1281387+iancoleman@users.noreply.github.com>2021-02-11 12:55:36 +1100
committerGitHub <noreply@github.com>2021-02-11 12:55:36 +1100
commit8835afe8a2a01bb189a8712c0797ea60566f553a (patch)
tree60a337d4347bff529aeac0bc79c952c243176c52 /libs/combined/index.js
parent71573cb3800ff7708ae19dd22aecf15660a41cc4 (diff)
parent6d2e202083c4166aa4be8557789a8a461df6bd5c (diff)
downloadBIP39-8835afe8a2a01bb189a8712c0797ea60566f553a.tar.gz
BIP39-8835afe8a2a01bb189a8712c0797ea60566f553a.tar.zst
BIP39-8835afe8a2a01bb189a8712c0797ea60566f553a.zip
Merge pull request #462 from zoobc/master
Add ZooBC coin support
Diffstat (limited to 'libs/combined/index.js')
-rw-r--r--libs/combined/index.js33
1 files changed, 33 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');