HomePhabricator

[Cashtab] More clarity and tests for address parsing

Description

[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

Details

Provenance
Joey King <joseph.roy.king@gmail.com>Authored on Jan 18 2021, 17:32
bytesofmanPushed on Jan 18 2021, 23:17
Reviewer
Restricted Project
Differential Revision
D8948: [Cashtab] More clarity and tests for address parsing
Parents
rABC634c08afae92: rpc: Add doc for deactivating settxfee and respect -maxtxfee wallet setting
Branches
Unknown
Tags
Unknown