Skip to content

Commit

Permalink
added zcash
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry Xiang authored and MichaelMure committed Jan 22, 2018
1 parent 83c9995 commit 122e676
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
19 changes: 13 additions & 6 deletions index.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4768,7 +4768,12 @@
var hash = this.hash.slice(0);

// Version
hash.unshift(janin.currency.networkVersion());
var networkVersion = janin.currency.networkVersion();
if (networkVersion instanceof Array) {
hash = networkVersion.concat(hash);
} else {
hash.unshift(networkVersion);
}
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
var bytes = hash.concat(checksum.slice(0, 4));
return Bitcoin.Base58.encode(bytes);
Expand All @@ -4783,13 +4788,14 @@
*/
Bitcoin.Address.decodeString = function (string) {
var bytes = Bitcoin.Base58.decode(string);
var hash = bytes.slice(0, 21);
var length = bytes.length;
var hash = bytes.slice(0, length - 4);
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });

if (checksum[0] != bytes[21] ||
checksum[1] != bytes[22] ||
checksum[2] != bytes[23] ||
checksum[3] != bytes[24]) {
if (checksum[0] != bytes[length - 4] ||
checksum[1] != bytes[length - 3] ||
checksum[2] != bytes[length - 2] ||
checksum[3] != bytes[length - 1]) {
throw "Checksum validation failed!";
}

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


Expand Down
Binary file added logos/zcash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 12 additions & 6 deletions src/bitcoinjs-lib.address.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ Bitcoin.Address.prototype.toString = function () {
var hash = this.hash.slice(0);

// Version
hash.unshift(janin.currency.networkVersion());
var networkVersion = janin.currency.networkVersion();
if (networkVersion instanceof Array) {
hash = networkVersion.concat(hash);
} else {
hash.unshift(networkVersion);
}
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
var bytes = hash.concat(checksum.slice(0, 4));
return Bitcoin.Base58.encode(bytes);
Expand All @@ -31,13 +36,14 @@ Bitcoin.Address.prototype.getHashBase64 = function () {
*/
Bitcoin.Address.decodeString = function (string) {
var bytes = Bitcoin.Base58.decode(string);
var hash = bytes.slice(0, 21);
var length = bytes.length;
var hash = bytes.slice(0, length - 4);
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });

if (checksum[0] != bytes[21] ||
checksum[1] != bytes[22] ||
checksum[2] != bytes[23] ||
checksum[3] != bytes[24]) {
if (checksum[0] != bytes[length - 4] ||
checksum[1] != bytes[length - 3] ||
checksum[2] != bytes[length - 2] ||
checksum[3] != bytes[length - 1]) {
throw "Checksum validation failed!";
}

Expand Down
1 change: 1 addition & 0 deletions src/janin.currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ janin.currencies = [
janin.currency.createCurrency ("WeAreSatoshiCoin", 0x87, 0x97, "6", "P" , "wSEgPsCGqQESLDyzBJkwCXvMP1z3e1Qi3X"),
janin.currency.createCurrency ("WorldCoin", 0x49, 0xc9, "7", "W" , "WNmGkn2WQZKS6xKHEsj5AqSbuE4sh9Upyb"),
janin.currency.createCurrency ("XP", 0x4b, 0xcb, "7", "X" , "XLRykcGjFMpBDQ7PHfamR2DR4Z21qTUBHG"),
janin.currency.createCurrency ("Zcash", [0x1c,0xb8], 0x80, "5", "[LK]" , ""),
janin.currency.createCurrency ("Zetacoin", 0x50, 0xE0, "8", "a" , "ZRU6TP8NLzoyey4DPPaa3uCCgDNDc96PXJ"),


Expand Down
Binary file added wallets/zcash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 122e676

Please sign in to comment.