aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/cosmos-util.js13
-rw-r--r--src/js/index.js13
2 files changed, 26 insertions, 0 deletions
diff --git a/src/js/cosmos-util.js b/src/js/cosmos-util.js
new file mode 100644
index 0000000..a7f4605
--- /dev/null
+++ b/src/js/cosmos-util.js
@@ -0,0 +1,13 @@
1function CosmosBufferToPublic(pubBuf) {
2 const Buffer = libs.buffer.Buffer;
3 const AminoSecp256k1PubkeyPrefix = Buffer.from("EB5AE987", "hex");
4 const AminoSecp256k1PubkeyLength = Buffer.from("21", "hex");
5 pubBuf = Buffer.concat([AminoSecp256k1PubkeyPrefix, AminoSecp256k1PubkeyLength, pubBuf]);
6 return libs.bech32.encode("cosmospub", libs.bech32.toWords(pubBuf));
7}
8
9function CosmosBufferToAddress(pubBuf) {
10 const sha256_ed = libs.createHash("sha256").update(pubBuf).digest();
11 const ripemd160_ed = libs.createHash("rmd160").update(sha256_ed).digest();
12 return libs.bech32.encode("cosmos", libs.bech32.toWords(ripemd160_ed));
13}
diff --git a/src/js/index.js b/src/js/index.js
index 713b5e8..96fc451 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -1419,6 +1419,12 @@
1419 privkey = FIObufferToPrivate(keyPair.d.toBuffer(32)); 1419 privkey = FIObufferToPrivate(keyPair.d.toBuffer(32));
1420 } 1420 }
1421 1421
1422 if (networks[DOM.network.val()].name == "ATOM - Cosmos Hub") {
1423 address = CosmosBufferToAddress(keyPair.getPublicKeyBuffer());
1424 pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer());
1425 privkey = keyPair.d.toBuffer().toString("base64");
1426 }
1427
1422 //Groestlcoin Addresses are different 1428 //Groestlcoin Addresses are different
1423 if(isGRS()) { 1429 if(isGRS()) {
1424 1430
@@ -2235,6 +2241,13 @@
2235 }, 2241 },
2236 }, 2242 },
2237 { 2243 {
2244 name: "ATOM - Cosmos Hub",
2245 onSelect: function() {
2246 network = libs.bitcoin.networks.bitcoin;
2247 setHdCoin(118);
2248 },
2249 },
2250 {
2238 name: "AUR - Auroracoin", 2251 name: "AUR - Auroracoin",
2239 onSelect: function() { 2252 onSelect: function() {
2240 network = libs.bitcoin.networks.auroracoin; 2253 network = libs.bitcoin.networks.auroracoin;