Skip to content

Commit

Permalink
Merge pull request #20 from zeppelin/add-bcash
Browse files Browse the repository at this point in the history
Add Bitcoin Cash
  • Loading branch information
ognus authored Apr 4, 2018
2 parents 3358226 + 19a7fa9 commit 3cf5f37
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ npm install wallet-address-validator
* BeaverCoin/BVC, `'beavercoin'` or `'BVC'`
* Biocoin/BIO, `'biocoin'` or `'BIO'`
* Bitcoin/BTC, `'bitcoin'` or `'BTC'`
* BitcoinCash/BCH, `'bitcoincash'` or `'BCH'`
* BitcoinGold/BTG, `'bitcoingold'` or `'BTG'`

* Callisto/CLO, `'callisto'` or `'CLO'`
Expand Down
4 changes: 4 additions & 0 deletions dist/wallet-address-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3250,6 +3250,10 @@ var CURRENCIES = [{
name: 'bitcoin',
symbol: 'btc',
addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}
},{
name: 'bitcoincash',
symbol: 'bch',
addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}
},{
name: 'litecoin',
symbol: 'ltc',
Expand Down
2 changes: 1 addition & 1 deletion dist/wallet-address-validator.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ var CURRENCIES = [{
name: 'bitcoin',
symbol: 'btc',
addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}
},{
name: 'bitcoincash',
symbol: 'bch',
addressTypes: {prod: ['00', '05'], testnet: ['6f', 'c4']}
},{
name: 'litecoin',
symbol: 'ltc',
Expand Down
21 changes: 21 additions & 0 deletions test/wallet_address_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ describe('WAValidator.validate()', function () {
valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoin', 'testnet');
});

it('should return true for correct bitcoincash addresses', function () {
valid('12KYrjTdVGjFMtaxERSk3gphreJ5US8aUP', 'bitcoincash');
valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bitcoincash');
valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'BCH');
valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'Bitcoin');
valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch');
valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'prod');
valid('12QeMLzSrB8XH8FvEzPMVoRxVAzTr5XM2y', 'bch', 'both');
valid('1oNLrsHnBcR6dpaBpwz3LSwutbUNkNSjs', 'bitcoincash');
valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'testnet');
valid('mzBc4XEFSdzCDcTxAgf6EZXgsZWpztRhef', 'bitcoincash', 'both');

// p2sh addresses
valid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'bitcoincash');
valid('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'bitcoincash', 'testnet');
});

it('should return true for correct litecoin addresses', function () {
valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'litecoin');
valid('LVg2kJoFNg45Nbpy53h7Fe1wKyeXVRhMH9', 'LTC');
Expand Down Expand Up @@ -259,6 +276,10 @@ describe('WAValidator.validate()', function () {
commonTests('bitcoin');
});

it('should return false for incorrect bitcoincash addresses', function () {
commonTests('bitcoincash');
});

it('should return false for incorrect litecoin addresses', function () {
commonTests('litecoin');
});
Expand Down

0 comments on commit 3cf5f37

Please sign in to comment.