[Cashtab] More clarity and tests for address parsing
Summary:
Adding support for approved address prefixes beyond the BCH standard creates complications with legacy validation libraries which only work with bitcoincash: prefix addresses (or prefix-less addresses that are checksum valid for the bitcoincash: prefix). This diff better organizes the methods needed to support this interface.
Changes
- Make the bitcoincash legacy prefix a constant as it is used in multiple places
- Rename isCash and isToken functions to be more descriptive about their functionality
- Accept no prefix as a valid prefix for cash addresses (but not token addresses)
- Remove : from approved prefix strings in input array as it applies to all prefixes
- Add unit tests
Test Plan: npm test
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D8948