Swyftx / crypto-address-validator

Useful library for validation of Bitcoin, Litecoin, Ethereum and other cryptocoin addresses
MIT License
71 stars 46 forks source link

BitcoinCash Address validation #40

Closed Paulsky closed 4 years ago

Paulsky commented 4 years ago

Currently, the validator only supports legacy BitcoinCash addresses. The new 'SLP' or 'Cash' (bitcoincash:xxx) addresses are not supported.

I could create a PR for a standalone BCH validator, and use this project https://github.com/bitcoincashjs/bchaddrjs as a dependency? Similar as the IOTA approach?

What are your thoughts about this?

GusGold commented 4 years ago

Hey @Paulsky

Sounds great.

Thoughts on being able to choose if the new cash address should be accepted or not. Even though it's the new thing, it's not widely adopted yet, and as such, not everyone may want to have it be validated.

Perhaps a forth argument addressFormat for validate, which can be an array of legacy, slp and/or cash?

Paulsky commented 4 years ago

Hello @GusGold ,

Alright, thanks! I will create a PR with a dedicated BCH validator and add a fourth argument for the validate function. I think you made a valid point, so I will make it an optional parameter. By default, it would only use the legacy option, so this will not be a breaking change.

How does that sound to you?

GusGold commented 4 years ago

Perfect!

Looking forward to the PR