Page MenuHomePhabricator

[ecashaddrjs] Add isValidCashAddress function
ClosedPublic

Authored by bytesofman on Apr 12 2023, 23:18.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCcaec6af0a8c4: [ecashaddrjs] Add isValidCashAddress function
Summary

T3115

Add new function to validate cash addresses.

  • Returns false for a legacy address
  • Returns true for a cashaddress
  • Optional: specify prefix, so return true for a valid ecash: address with ecash: prefix, but false for valid cashaddress with bitcoincash: prefix

This is done by a couple of functions in Cashtab. Should be one function in this library. Would be useful for other developers looking to have validation by cashaddress type.

Test Plan

Review new function and unit tests.
npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
add-isvalidaddr
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23265
Build 46149: Build Diffecashaddrjs-tests
Build 46148: arc lint + arc unit

Event Timeline

Fabien added a subscriber: Fabien.
Fabien added inline comments.
modules/ecashaddrjs/src/cashaddr.js
560

It returns a bool

This revision is now accepted and ready to land.Apr 13 2023, 09:13