From 661896b1ca97db36c1cb97a6854e192d43a5cff0 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Fri, 5 Apr 2019 13:45:11 +0000 Subject: [PATCH 1/7] Ability to validate 'zs' addresses, added Pirate Chain (ARRR) coin --- src/crypto/segwit_addr.js | 32 +++++++++++++++++++++----------- src/currencies.js | 5 ++++- test/wallet_address_validator.js | 27 +++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/crypto/segwit_addr.js b/src/crypto/segwit_addr.js index a82fcc8e..0ba04055 100644 --- a/src/crypto/segwit_addr.js +++ b/src/crypto/segwit_addr.js @@ -49,21 +49,26 @@ function convertbits (data, frombits, tobits, pad) { function decode (hrp, addr) { var dec = bech32.decode(addr); - if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) { - return null; - } - var res = convertbits(dec.data.slice(1), 5, 8, false); - if (res === null || res.length < 2 || res.length > 40) { - return null; - } - if (dec.data[0] === 0 && res.length !== 20 && res.length !== 32) { - return null; + if (dec === null || dec.hrp !== hrp || + (hrp === 'zs' && dec.data.length < 68) || + (hrp !== 'zs' && (dec.data.length < 1 || dec.data[0] > 16)) + ) return null; + + var res = convertbits(hrp === 'zs' ? dec.data : dec.data.slice(1), 5, 8, false); + if (res === null || + (hrp === 'zs' && res.length < 42) || + (hrp !== 'zs' && (res.length < 2 || res.length > 40)) + ) return null; + + if (hrp !== 'zs' && (dec.data[0] === 0 && res.length !== 20 && res.length !== 32)) { + return null; } return {version: dec.data[0], program: res}; } function encode (hrp, version, program) { - var ret = bech32.encode(hrp, [version].concat(convertbits(program, 8, 5, true))); + var convertedBits = hrp === 'zs' ? convertbits(program, 8, 5, true) : [version].concat(convertbits(program, 8, 5, true)); + var ret = bech32.encode(hrp, convertedBits); if (decode(hrp, ret) === null) { return null; } @@ -71,9 +76,14 @@ function encode (hrp, version, program) { } function isValidAddress(address) { - var hrp = 'bc'; + var hrp = 'zs'; var ret = decode(hrp, address); + if (ret === null) { + hrp = 'bc'; + ret = decode(hrp, address); + } + if (ret === null) { hrp = 'tb'; ret = decode(hrp, address); diff --git a/src/currencies.js b/src/currencies.js index 993515e9..6a36ad8f 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -94,7 +94,6 @@ var CURRENCIES = [{ symbol: 'vtc', addressTypes: { prod: ['0x', '47', '71', '05'], testnet: ['6f', 'c4'] }, validator: BTCValidator - }, { name: 'BitcoinGold', symbol: 'btg', @@ -404,6 +403,10 @@ var CURRENCIES = [{ name: 'stellar', symbol: 'xlm', validator: XLMValidator, +}, { + name: 'pirate', + symbol: 'arrr', + validator: BTCValidator, }]; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index ffcc00d3..4d88e1a2 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -225,7 +225,7 @@ describe('WAValidator.validate()', function () { valid('353nERPQKhGj4WGzoiWcareA76TPgRCVNA', 'VTC'); valid('376g4TmL8uQKFYsRFrbv5iz9srmb5bocEt', 'VTC'); valid('3AMtM4Zk5oNHu9i4jDiwKB6Kg5YEReBsav', 'VTC'); - + valid('VmoMjGf3zgZLy8sk3PMKd3xikZHXWvnYi7', 'vertcoin'); valid('VmhHwXr3J8xMZpy62WuBGpu3xVvThWzcTQ', 'vertcoin'); valid('mvww6DEJ18dbyQUukpVQXvLgrNDJazZn1Y', 'vertcoin', 'testnet'); @@ -311,7 +311,7 @@ describe('WAValidator.validate()', function () { valid('MCgyroQse81wuv5RwPpY5DXDNxeafzLFJ8', 'QTUM'); valid('QQYySVc5WEe3g6PnNFYmspqG5CfSG8rnma', 'QTUM'); valid('MSvJQBJMZs1dhxz7UAWa2si4iyMD2FHQd5', 'QTUM'); - + valid('qcSLSxN1sngCWSrKFZ6UC7ri4hhVSdq9SU', 'qtum', 'testnet'); valid('qJnbEdrm9ybjVqDCaX5SWNBHmZy2X7YbPT', 'qtum', 'testnet'); valid('qchBPDUYswobzpDmY5DsTStt74sTYQtaQv', 'qtum', 'testnet'); @@ -546,7 +546,14 @@ describe('WAValidator.validate()', function () { valid('GACXQEAXYBEZLBMQ2XETOBRO4P66FZAJENDHOQRYPUIXZIIXLKMZEXBJ', 'stellar'); valid('GDD3XRXU3G4DXHVRUDH7LJM4CD4PDZTVP4QHOO4Q6DELKXUATR657OZV', 'stellar'); valid('GDTYVCTAUQVPKEDZIBWEJGKBQHB4UGGXI2SXXUEW7LXMD4B7MK37CWLJ', 'stellar'); - }); + }); + + it('should return true for correct pirate chain addresses', function () { + valid('zs1ewm4czrf2drr6awvxpmaq2enkrjk9alhdzvxyej44rp2mkvc3mdazfgy0ajtr4n0hg2k5anxsgq', 'pirate'); + valid('zs1fnug4zz7wmfvr48zg6t28j9ykr5uyrs2e2k6pg0n8870mnx0z6mrh5h2k3hx56q5nfe9skzq5cz', 'pirate'); + valid('zs1xylu42dht08zy4p5c7lgzhh42m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'arrr'); + valid('zs1xylu42dht08zy4p5c7lgzhh42m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'ARRR'); + }); }); describe('invalid results', function () { @@ -861,6 +868,18 @@ describe('WAValidator.validate()', function () { invalid('SAB5556L5AN5KSR5WF7UOEFDCIODEWEO7H2UR4S5R62DFTQOGLKOVZDY', 'stellar'); invalid('gWRYUerEKuz53tstxEuR3NCkiQDcV4wzFHmvLnZmj7PUqxW2wt', 'stellar'); invalid('g4VPBPrHZkfE8CsjuG2S4yBQNd455UWmk', 'stellar'); - }); + }); + + it('should return false for incorrect pirate chain addresses', function () { + commonTests('pirate'); + invalid('t1Y9yhDa5XEjgfnTgZoKddeSiEN1aoLkQxq', 'pirate'); + invalid('t3Yz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd', 'arrr'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'pirate', 'testnet'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'arrr', 'testnet'); + invalid('zs1ewm4czrf2drr6awvxcmaq2enkrjk9alhdzvxyej44rp2mkvc3mdazfgy0ajtr4n0hg2k5anxsgq', 'pirate'); + invalid('zs1fnug4zz7wmfvr48zg6t2gj9ykr5uyrs2e2k6pg0n8870mnx0z6mrh5h2k3hx56q5nfe9skzq5cz', 'pirate'); + invalid('zs1xylu42dht08zy4p5c7lgzhhv2m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'arrr'); + invalid('zs1xylu42dht08zy4p5cglgzhl42m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'ARRR'); + }); }); }); From cabbc42a87841acea2a6ee2894722e4329322c59 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Fri, 5 Apr 2019 13:50:40 +0000 Subject: [PATCH 2/7] Updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3c221777..58c26680 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ npm install multicoin-address-validator * Odyssey/ocn `'Odyssey'` or `'ocn'` * OmiseGO/omg `'OmiseGO'` or `'omg'` * PeerCoin/ppc `'PeerCoin'` or `'ppc'` +* PirateChain/arrr `'ARRR'` or `'arrr'` * PIVX/pivx `'PIVX'` or `'pivx'` * Polymath/poly `'Polymath'` or `'poly'` * PrimeCoin/xpm `'PrimeCoin'` or `'xpm'` From fd3f31079f685c7c0fb536f131409fd6ab23457d Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Tue, 14 May 2019 11:24:00 +0000 Subject: [PATCH 3/7] Updated Monero validator, added Wownero (WOW) and Zano (ZAN) coins --- README.md | 2 ++ package.json | 4 ++- src/currencies.js | 18 ++++++++++++ src/monero_validator.js | 49 +++++++++++++++++++++----------- test/wallet_address_validator.js | 31 ++++++++++++++++++++ 5 files changed, 87 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 58c26680..6aa6808a 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,8 @@ npm install multicoin-address-validator * VoteCoin/vot `'VoteCoin'` or `'vot'` * Waves/waves `'Waves'` or `'waves'` * Wings/wings `'Wings'` or `'wings'` +* Wownero/wow `'Wownero'` or `'wow'` +* Zano/zan `'Zano'` or `'zan'` * ZCash/zec `'ZCash'` or `'zec'` * ZClassic/zcl `'ZClassic'` or `'zcl'` * ZenCash/zen `'ZenCash'` or `'zen'` diff --git a/package.json b/package.json index c4b6420c..c5f7eadc 100644 --- a/package.json +++ b/package.json @@ -55,9 +55,11 @@ "dependencies": { "base-x": "^3.0.5", "browserify-bignum": "^1.3.0-2", + "buffer-ponyfill": "^0.1.1", "cbor-js": "^0.1.0", "crc": "^3.8.0", - "jssha": "2.3.1" + "jssha": "2.3.1", + "varint": "^5.0.0" }, "devDependencies": { "browserify": "^16.2.3", diff --git a/src/currencies.js b/src/currencies.js index 6a36ad8f..cd113874 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -407,6 +407,24 @@ var CURRENCIES = [{ name: 'pirate', symbol: 'arrr', validator: BTCValidator, +}, { + name: 'wownero', + symbol: 'wow', + addressTypes: { prod: ['4146'], testnet: ['53'] }, + iAddressTypes: { prod: ['6810'], testnet: ['54'] }, + expectedLength: 97, + expectedIntegratedLength: 108, + expectedTestnetLength: 95, + expectedIntegratedTestnetLength: 106, + validator: XMRValidator, +}, { + name: 'zano', + symbol: 'zan', + addressTypes: { prod: ['197'], testnet: [] }, + iAddressTypes: { prod: [0x3678], testnet: [] }, + expectedLength: 97, + expectedIntegratedLength: 108, + validator: XMRValidator, }]; diff --git a/src/monero_validator.js b/src/monero_validator.js index fd78064d..c3c12dc2 100644 --- a/src/monero_validator.js +++ b/src/monero_validator.js @@ -1,28 +1,32 @@ -var cryptoUtils = require('./crypto/utils') -var cnBase58 = require('./crypto/cnBase58') +var Buffer = require('buffer-ponyfill') +var varint = require('varint'); +var cryptoUtils = require('./crypto/utils'); +var cnBase58 = require('./crypto/cnBase58'); var DEFAULT_NETWORK_TYPE = 'prod' -var addressRegTest = new RegExp( - '^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$' +var addressRegTest = len => new RegExp( + `^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{${len || 95}}$` ) -var integratedAddressRegTest = new RegExp( - '^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$' +var integratedAddressRegTest = len => new RegExp( + `^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{${len || 106}}$` ) function validateNetwork(decoded, currency, networkType, addressType) { var network = currency.addressTypes - if (addressType == 'integrated') { + if (addressType === 'integrated') { network = currency.iAddressTypes } - var at = parseInt(decoded.substr(0, 2), 16).toString() + const at = varint.decode(Buffer.from(decoded, 'hex')); + const isInProd = network.prod.indexOf(at) >= 0 || network.prod.indexOf(at.toString()) >= 0 + const isInTestnet = network.testnet.indexOf(at) >= 0 || network.testnet.indexOf(at.toString()) >= 0 switch (networkType) { case 'prod': - return network.prod.indexOf(at) >= 0 + return isInProd case 'testnet': - return network.testnet.indexOf(at) >= 0 + return isInTestnet case 'both': - return network.prod.indexOf(at) >= 0 || network.testnet.indexOf(at) >= 0 + return isInProd || isInTestnet default: return false } @@ -41,11 +45,24 @@ module.exports = { isValidAddress: function(address, currency, networkType) { networkType = networkType || DEFAULT_NETWORK_TYPE var addressType = 'standard' - if (!addressRegTest.test(address)) { - if (integratedAddressRegTest.test(address)) { - addressType = 'integrated' - } else { - return false + + if (networkType === 'prod') { + if (!addressRegTest(currency.expectedLength).test(address)) { + if (integratedAddressRegTest(currency.expectedIntegratedLength).test(address)) { + addressType = 'integrated' + } else { + return false + } + } + } + + if (networkType === 'testnet') { + if (!addressRegTest(currency.expectedTestnetLength).test(address)) { + if (integratedAddressRegTest(currency.expectedIntegratedTestnetLength).test(address)) { + addressType = 'integrated' + } else { + return false + } } } diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 4d88e1a2..ede2e5df 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -554,6 +554,21 @@ describe('WAValidator.validate()', function () { valid('zs1xylu42dht08zy4p5c7lgzhh42m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'arrr'); valid('zs1xylu42dht08zy4p5c7lgzhh42m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'ARRR'); }); + + it('should return true for correct wownero addresses', function () { + valid('So2ifgjqGMZJhCrqpFMotQQAiJAiATuJLNAK2HrPLoNzK8hkqNbf9t8gmx6bzAQrXRMnWnoELoiD6GTv8guPBRwH5ynAzv9j4PK16dmXNsuc', 'wow'); + valid('Wo4m7F7syuvCgDsX4TJ7LPHwoKEJmApmzGpEicfQpWNY6nGqSHAxrGx8EbxhN6usL5645Cj1oKPnk5hdCfrAhLhx1kZHEft8q', 'wownero'); + valid('Wo5F2arB93E6EPM11URsH61afYW2oP6PG8b2ZdEafzKHFG7SbGuUQDeHzN3kQuBMzNbUygE4847AhFB4zMjKrX552j2HVLb3j', 'wow'); + valid('9zuKdp6MrQaBSw85QP2fFh8zznN8tPbpJQZhX6wyVGHb5TdJu4QYcPK7EtfhUtnYbVUCFkNM9sPfViN5HvmXxV9iEVJP2o8', 'wow', 'testnet'); + }); + + it('should return true for correct zano addresses', function () { + valid('iZ1gc2mQWmG6uZ8Hd13KZ7bqa2YDTreGCNbYAJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm7cyQkAkbabz35owWPtiV5gzKExpvRx31uQdtear8', 'zan'); + valid('ZxCXrAt8wRgNTEdAejBuvTF5bPmxE47SJ5feYUEyekuKa7ufxcxJC7xXV1tweXNTv6gBxvMqGz8p99nKY3SZirp32afpteMRi', 'zano'); + valid('ZxCCUjfrShx6uZ8Hd13KZ7bqa2YDTreGCNbYAJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm7cyQkAkbabz35owWPtiV1ExkyteaA', 'zan'); + valid('ZxDNdmYqVuA1RbQmHW2KR4cZifZV5hUrygGEfwgtCvq9RN8uud747SZ27wf6ZDhmeU9qxjYwCe3zEgEEfT66pSxk1E6znvszn', 'zan'); + valid('iZ1gc2mQWmG6uZ8Hd13KZ7bqa2YDTreGCNbYAJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm7cyQkAkbabz35owWPtiV5gyuTwmWw2g2Fu8LUT69', 'zan'); + }); }); describe('invalid results', function () { @@ -881,5 +896,21 @@ describe('WAValidator.validate()', function () { invalid('zs1xylu42dht08zy4p5c7lgzhhv2m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'arrr'); invalid('zs1xylu42dht08zy4p5cglgzhl42m350c0sppgqcxwvjvwqraxgq9m9yj356egmatn0q88zvu3jyu0', 'ARRR'); }); + + it('should return false for incorrect wownero addresses', function () { + commonTests('wownero'); + invalid('So2ifgjqGMZJhCrqpFMotQQAiJAiATuJLNAK2HrPLoNx18hkqNbf9t8gmx6bzAQrXRMnWnoELoiD6GTv8guPBRwH5ynAzv9j4PK16dmXNsuc', 'wow'); + invalid('Wo4m7F7syuvCgDsX4TJ7LPHwoKEJmApmzGx1icfQpWNY6nGqSHAxrGx8EbxhN6usL5645Cj1oKPnk5hdCfrAhLhx1kZHEft8q', 'wownero'); + invalid('Wo5F2arB93E6EPM11URsH61x1YW2oP6PG8b2ZdEafzKHFG7SbGuUQDeHzN3kQuBMzNbUygE4847AhFB4zMjKrX552j2HVLb3j', 'wow'); + invalid('9zuKdp6MrQaBSw85QP2fFh8zznN8tPx1JQZhX6wyVGHb5TdJu4QYcPK7EtfhUtnYbVUCFkNM9sPfViN5HvmXxV9iEVJP2o8', 'wow', 'testnet'); + }); + + it('should return false for incorrect zano addresses', function () { + invalid('iZ1gc2mQWmG7uZ8Hd13KZ7bqa2YDTreGCNbYAJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm7cyQkAkbabz35owWPtiV5gzKExpvRx31uQdtear8', 'zan'); + invalid('ZxCXrAt8wRgNTEdAejBuvTF5bPmxE4111111YUEyekuKa7ufxcxJC7xXV1tweXNTv6gBxvMqGz8p99nKY3SZirp32afpteMRi', 'zano'); + invalid('ZxCCUjfrShx6uZ8Hd13KZ7bqa3YDTr111111AJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm7cyQkAkbabz35owWPtiV1ExkyteaA', 'zan'); + invalid('ZxDNdmYqVuA1RbQmHW2KR4cZifZV6h111111fwgtCvq9RN8uud747SZ27wf6ZDhmeU9qxjYwCe3zEgEEfT66pSxk1E6znvszn', 'zan'); + invalid('iZ1gc2mQWmG6uZ8Hd13KZ7bqa2YDTr111111AJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm8cyQkAkbabz35owWPtiV5gyuTwmWw2g2Fu8LUT69', 'zan'); + }); }); }); From 919ef1c8ac203b7bb78b11e0ab3a264a004602e2 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Fri, 24 May 2019 11:56:37 +0000 Subject: [PATCH 4/7] Added Conceal (CCX) coin --- README.md | 1 + src/currencies.js | 6 ++++++ test/wallet_address_validator.js | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/README.md b/README.md index 6aa6808a..81cb7c96 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ npm install multicoin-address-validator * Callisto/clo `'Callisto'` or `'clo'` * Cardano/ada `'Cardano'` or `'ada'` * Civic/cvc `'Civic'` or `'cvc'` +* Conceal/ccx `'Conceal'` or `'ccx'` * Dash/dash `'Dash'` or `'dash'` * Decred/dcr `'Decred'` or `'dcr'` * DigiByte/dgb `'DigiByte'` or `'dgb'` diff --git a/src/currencies.js b/src/currencies.js index cd113874..adfb3706 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -425,6 +425,12 @@ var CURRENCIES = [{ expectedLength: 97, expectedIntegratedLength: 108, validator: XMRValidator, +}, { + name: 'conceal', + symbol: 'ccx', + addressTypes: { prod: [0x7ad4], testnet: [] }, + expectedLength: 98, + validator: XMRValidator, }]; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index ede2e5df..e73e1852 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -569,6 +569,15 @@ describe('WAValidator.validate()', function () { valid('ZxDNdmYqVuA1RbQmHW2KR4cZifZV5hUrygGEfwgtCvq9RN8uud747SZ27wf6ZDhmeU9qxjYwCe3zEgEEfT66pSxk1E6znvszn', 'zan'); valid('iZ1gc2mQWmG6uZ8Hd13KZ7bqa2YDTreGCNbYAJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm7cyQkAkbabz35owWPtiV5gyuTwmWw2g2Fu8LUT69', 'zan'); }); + + it('should return true for correct conceal addresses', function () { + valid('ccx7eC5fEABK1wyrJWiuaThKtU7LbfrzaUfj1diAvKtj6fFRpR2ymbqXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZi71SCy', 'conceal'); + valid('ccx7Jibx3n75V4myunVdyJDuyuTsQvkMeAq7UUpurbr4Lt8jBzwMApTXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZiTQu9u', 'ccx'); + valid('ccx7fWv9D56UBVnU6TVn7DAQEvCUv9CiFHfqcLNdjTMp8DdpZ5cVqyYL7DEzCBBC7w2BaAzqnAe1aKPdyuEqpRic5USXtBTSbX', 'ccx'); + valid('ccx7BnTqX4eAbU7NQPJ6ieAHLyNcRApFiMZVR35fiZzfeoh5HwxGxZZXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZhzjWQ3', 'ccx'); + valid('ccx7XekEfeBbMbbe96kw9i5zh38woeKdtT98qG6UWu7UhMj9sn4Av7FMKPHQWjigxLg3b2YE2a7TMitmwTLuf6CG3hM8vSCmwT', 'ccx'); + valid('ccx7JVxUaCgYeyEBgRtTGwBEMFG23fHPZ36E9Z3oP2L2SkLsV99qWohbdND31jPHZy8Y3qsyxVH9bfWZT8e76XHn8MrZWHnL7C', 'ccx'); + }); }); describe('invalid results', function () { @@ -912,5 +921,13 @@ describe('WAValidator.validate()', function () { invalid('ZxDNdmYqVuA1RbQmHW2KR4cZifZV6h111111fwgtCvq9RN8uud747SZ27wf6ZDhmeU9qxjYwCe3zEgEEfT66pSxk1E6znvszn', 'zan'); invalid('iZ1gc2mQWmG6uZ8Hd13KZ7bqa2YDTr111111AJ7HHNfEPSxk7iCKpCsBfpFTPoLfvibm8cyQkAkbabz35owWPtiV5gyuTwmWw2g2Fu8LUT69', 'zan'); }); + + it('should return false for incorrect conceal addresses', function () { + invalid('ccx8eC5fEABK1wyrJWiuaThKtU7LbfrzaUfj1diAvKtj6fFRpR2ymbqXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZi71SCy', 'conceal'); + invalid('ccxxJibx3n75V4myunVdyJDuyuTsQvkMeAq7UUpurbr4Lt8jBzwMApTXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZiTQu9u', 'ccx'); + invalid('ccx7xxv9D56UBVnU6TVn7DAQEvCUv9CiFHfqcLNdjTMp8DdpZ5cVqyYL7DEzCBBC7w2BaAzqnAe1aKPdyuEqpRic5USXtBTSbX', 'ccx'); + invalid('ccx7BnTqX4eAbU7NQPJ6ieAHLyNcRApFiMZVR35fiZzfeoh5HwxGxZZXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZhzjXXX', 'ccx'); + invalid('ccx7XekEfeBbMbbe96kw9i5zh38woeKdtT98qG6UWu7UhMj9sn4Av7FMKPHQWjigxLg3b2YE2a7TMitmwTLuf6CG3hM81', 'ccx'); + }); }); }); From a44b26f485126287909afede602c07e9b7e57bc6 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Sat, 25 May 2019 19:51:14 +0000 Subject: [PATCH 5/7] Added ZelCash (ZEL) coin --- README.md | 1 + src/currencies.js | 6 ++++++ test/wallet_address_validator.js | 14 ++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 81cb7c96..a704fd41 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ npm install multicoin-address-validator * Zano/zan `'Zano'` or `'zan'` * ZCash/zec `'ZCash'` or `'zec'` * ZClassic/zcl `'ZClassic'` or `'zcl'` +* ZelCash/zel `'ZelCash'` or `'zel'` * ZenCash/zen `'ZenCash'` or `'zen'` ### Usage example diff --git a/src/currencies.js b/src/currencies.js index adfb3706..04a03a19 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -431,6 +431,12 @@ var CURRENCIES = [{ addressTypes: { prod: [0x7ad4], testnet: [] }, expectedLength: 98, validator: XMRValidator, +}, { + name: 'zelcash', + symbol: 'zel', + expectedLength: 26, + addressTypes: { prod: ['1cb8', '1cbd'], testnet: ['1d25', '1cba'] }, + validator: BTCValidator }]; diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index e73e1852..00abd61c 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -578,6 +578,13 @@ describe('WAValidator.validate()', function () { valid('ccx7XekEfeBbMbbe96kw9i5zh38woeKdtT98qG6UWu7UhMj9sn4Av7FMKPHQWjigxLg3b2YE2a7TMitmwTLuf6CG3hM8vSCmwT', 'ccx'); valid('ccx7JVxUaCgYeyEBgRtTGwBEMFG23fHPZ36E9Z3oP2L2SkLsV99qWohbdND31jPHZy8Y3qsyxVH9bfWZT8e76XHn8MrZWHnL7C', 'ccx'); }); + + it('should return true for correct zelcash addresses', function () { + valid('t1Zq7Efz5gsviNTxFnnw5w3d2a57b89VZpg', 'zelcash'); + valid('t1a6XPhFV92w231ByvbZm8ZVkUTcv4PmxNY', 'zel'); + valid('t1cRh4vqjM1Q86s8F4yXHKjYj5Tdv5zTDda', 'zel'); + valid('t1ZtYoXA4rRR56LySQWryYLsEGWxdNFQVvE', 'zel'); + }); }); describe('invalid results', function () { @@ -929,5 +936,12 @@ describe('WAValidator.validate()', function () { invalid('ccx7BnTqX4eAbU7NQPJ6ieAHLyNcRApFiMZVR35fiZzfeoh5HwxGxZZXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZhzjXXX', 'ccx'); invalid('ccx7XekEfeBbMbbe96kw9i5zh38woeKdtT98qG6UWu7UhMj9sn4Av7FMKPHQWjigxLg3b2YE2a7TMitmwTLuf6CG3hM81', 'ccx'); }); + + it('should return false for incorrect zelcash addresses', function () { + invalid('t1XX7Efz5gsviNTxFnnw5w3d2a57b89VZpg', 'zelcash'); + invalid('t1a6XPhFV92w231ByvbZm8ZVkUTcv4Pmx', 'zel'); + invalid('t1cRh4vqjM1Q86s8XXyXHKjYj5Tdv5zTDda', 'zel'); + invalid('t1ZtYoXA4rRR56LySQWryYLsEGWxdNFQVvEXX', 'zel'); + }); }); }); From 023ac779535fc51f57d7c325bd120ead72da089f Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Sun, 1 Mar 2020 13:29:05 +0000 Subject: [PATCH 6/7] Validating Conceal (CCX) integrated addresses --- src/currencies.js | 2 ++ test/wallet_address_validator.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/currencies.js b/src/currencies.js index 04a03a19..c6580660 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -429,7 +429,9 @@ var CURRENCIES = [{ name: 'conceal', symbol: 'ccx', addressTypes: { prod: [0x7ad4], testnet: [] }, + iAddressTypes: { prod: [0x7ad4], testnet: [] }, expectedLength: 98, + expectedIntegratedLength: 186, validator: XMRValidator, }, { name: 'zelcash', diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 00abd61c..8e5a96ab 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -577,6 +577,7 @@ describe('WAValidator.validate()', function () { valid('ccx7BnTqX4eAbU7NQPJ6ieAHLyNcRApFiMZVR35fiZzfeoh5HwxGxZZXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZhzjWQ3', 'ccx'); valid('ccx7XekEfeBbMbbe96kw9i5zh38woeKdtT98qG6UWu7UhMj9sn4Av7FMKPHQWjigxLg3b2YE2a7TMitmwTLuf6CG3hM8vSCmwT', 'ccx'); valid('ccx7JVxUaCgYeyEBgRtTGwBEMFG23fHPZ36E9Z3oP2L2SkLsV99qWohbdND31jPHZy8Y3qsyxVH9bfWZT8e76XHn8MrZWHnL7C', 'ccx'); + valid('ccx7NM9z2PSAZvJCQiCc2f94ipcK7GxZqAESAoa9XLq6HHpWQ1DLrCCHnxhRBBAkNX9u7cedGhz4F9RuTdY12bgE9bdxVSnFn9gLdmKfdS2qy9VdiBdDqcTbKLd21iP78on2NExDechEG98cR7pWS5PffYDa1cYQcj45PWxy2cWsNEer8eXGSJgibk', 'ccx'); }); it('should return true for correct zelcash addresses', function () { @@ -935,6 +936,7 @@ describe('WAValidator.validate()', function () { invalid('ccx7xxv9D56UBVnU6TVn7DAQEvCUv9CiFHfqcLNdjTMp8DdpZ5cVqyYL7DEzCBBC7w2BaAzqnAe1aKPdyuEqpRic5USXtBTSbX', 'ccx'); invalid('ccx7BnTqX4eAbU7NQPJ6ieAHLyNcRApFiMZVR35fiZzfeoh5HwxGxZZXtznxBsofFP8JB32YYBmtwLdoEirjAbYo4DBZhzjXXX', 'ccx'); invalid('ccx7XekEfeBbMbbe96kw9i5zh38woeKdtT98qG6UWu7UhMj9sn4Av7FMKPHQWjigxLg3b2YE2a7TMitmwTLuf6CG3hM81', 'ccx'); + invalid('ccx7NM9z2PXXXvJCQiCc2f94ipcK7GxZqAESAoa9XLq6HHpWQ1DLrCCHnxhRBBAkNX9u7cedGhz4F9RuTdY12bgE9bdxVSnFn9gLdmKfdS2qy9VdiBdDqcTbKLd21iP78on2NExDechEG98cR7pWS5PffYDa1cYQcj45PWxy2cWsNEer8eXGSJgibk', 'ccx'); }); it('should return false for incorrect zelcash addresses', function () { From f0336988d5e030cefefd48a043966a872781d153 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Mon, 7 Feb 2022 22:42:26 +0000 Subject: [PATCH 7/7] Buffer --- src/crypto/blake256.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/blake256.js b/src/crypto/blake256.js index b1811511..1fa9f46b 100644 --- a/src/crypto/blake256.js +++ b/src/crypto/blake256.js @@ -1,5 +1,5 @@ 'use strict'; - +var Buffer = require('buffer-ponyfill') /** * Credits to https://github.com/cryptocoinjs/blake-hash */