Skip to content

Commit 122e676

Browse files
Terry XiangMichaelMure
authored andcommitted
added zcash
1 parent 83c9995 commit 122e676

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

index.html

100644100755
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4768,7 +4768,12 @@
47684768
var hash = this.hash.slice(0);
47694769

47704770
// Version
4771-
hash.unshift(janin.currency.networkVersion());
4771+
var networkVersion = janin.currency.networkVersion();
4772+
if (networkVersion instanceof Array) {
4773+
hash = networkVersion.concat(hash);
4774+
} else {
4775+
hash.unshift(networkVersion);
4776+
}
47724777
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
47734778
var bytes = hash.concat(checksum.slice(0, 4));
47744779
return Bitcoin.Base58.encode(bytes);
@@ -4783,13 +4788,14 @@
47834788
*/
47844789
Bitcoin.Address.decodeString = function (string) {
47854790
var bytes = Bitcoin.Base58.decode(string);
4786-
var hash = bytes.slice(0, 21);
4791+
var length = bytes.length;
4792+
var hash = bytes.slice(0, length - 4);
47874793
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
47884794

4789-
if (checksum[0] != bytes[21] ||
4790-
checksum[1] != bytes[22] ||
4791-
checksum[2] != bytes[23] ||
4792-
checksum[3] != bytes[24]) {
4795+
if (checksum[0] != bytes[length - 4] ||
4796+
checksum[1] != bytes[length - 3] ||
4797+
checksum[2] != bytes[length - 2] ||
4798+
checksum[3] != bytes[length - 1]) {
47934799
throw "Checksum validation failed!";
47944800
}
47954801

@@ -10700,6 +10706,7 @@ <h3>Release notes</h3>
1070010706
janin.currency.createCurrency ("WeAreSatoshiCoin", 0x87, 0x97, "6", "P" , "wSEgPsCGqQESLDyzBJkwCXvMP1z3e1Qi3X"),
1070110707
janin.currency.createCurrency ("WorldCoin", 0x49, 0xc9, "7", "W" , "WNmGkn2WQZKS6xKHEsj5AqSbuE4sh9Upyb"),
1070210708
janin.currency.createCurrency ("XP", 0x4b, 0xcb, "7", "X" , "XLRykcGjFMpBDQ7PHfamR2DR4Z21qTUBHG"),
10709+
janin.currency.createCurrency ("Zcash", [0x1c,0xb8], 0x80, "5", "[LK]" , ""),
1070310710
janin.currency.createCurrency ("Zetacoin", 0x50, 0xE0, "8", "a" , "ZRU6TP8NLzoyey4DPPaa3uCCgDNDc96PXJ"),
1070410711

1070510712

logos/zcash.png

32.1 KB
Loading

src/bitcoinjs-lib.address.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ Bitcoin.Address.prototype.toString = function () {
1616
var hash = this.hash.slice(0);
1717

1818
// Version
19-
hash.unshift(janin.currency.networkVersion());
19+
var networkVersion = janin.currency.networkVersion();
20+
if (networkVersion instanceof Array) {
21+
hash = networkVersion.concat(hash);
22+
} else {
23+
hash.unshift(networkVersion);
24+
}
2025
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
2126
var bytes = hash.concat(checksum.slice(0, 4));
2227
return Bitcoin.Base58.encode(bytes);
@@ -31,13 +36,14 @@ Bitcoin.Address.prototype.getHashBase64 = function () {
3136
*/
3237
Bitcoin.Address.decodeString = function (string) {
3338
var bytes = Bitcoin.Base58.decode(string);
34-
var hash = bytes.slice(0, 21);
39+
var length = bytes.length;
40+
var hash = bytes.slice(0, length - 4);
3541
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
3642

37-
if (checksum[0] != bytes[21] ||
38-
checksum[1] != bytes[22] ||
39-
checksum[2] != bytes[23] ||
40-
checksum[3] != bytes[24]) {
43+
if (checksum[0] != bytes[length - 4] ||
44+
checksum[1] != bytes[length - 3] ||
45+
checksum[2] != bytes[length - 2] ||
46+
checksum[3] != bytes[length - 1]) {
4147
throw "Checksum validation failed!";
4248
}
4349

src/janin.currency.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ janin.currencies = [
278278
janin.currency.createCurrency ("WeAreSatoshiCoin", 0x87, 0x97, "6", "P" , "wSEgPsCGqQESLDyzBJkwCXvMP1z3e1Qi3X"),
279279
janin.currency.createCurrency ("WorldCoin", 0x49, 0xc9, "7", "W" , "WNmGkn2WQZKS6xKHEsj5AqSbuE4sh9Upyb"),
280280
janin.currency.createCurrency ("XP", 0x4b, 0xcb, "7", "X" , "XLRykcGjFMpBDQ7PHfamR2DR4Z21qTUBHG"),
281+
janin.currency.createCurrency ("Zcash", [0x1c,0xb8], 0x80, "5", "[LK]" , ""),
281282
janin.currency.createCurrency ("Zetacoin", 0x50, 0xE0, "8", "a" , "ZRU6TP8NLzoyey4DPPaa3uCCgDNDc96PXJ"),
282283

283284

wallets/zcash.png

571 KB
Loading

0 commit comments

Comments
 (0)