HomePhabricator

[ecashaddrjs] Support returning hash160 as string instead of uint8array

Description

[ecashaddrjs] Support returning hash160 as string instead of uint8array

Summary:
T3055

ecashaddrjs returns the hash of an address (aka hash160) as a uint8array. This is used in zero apps in the monorepo: Cashtab, alias-server, and ecash-telegram-bot all need special util functions to convert this to a string (since this is the format needed by chronik).

So that backward compatibility is not impacted, returning hash160 as a string from cashaddr.decode is a user-specified parameter that defaults to returning the old data.

Webpack updates are required to support the Buffer type in the browser. The webpack config is updated in the same way that it is in Cashtab to support the use of Buffer from nodejs modules in the browser. This was tested by installing this module into create-react-app and running the new functions.

Test Plan: Review new helper functions, changes to existing encode and decode functions, and accompanying unit tests.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D13494

Details

Provenance
bytesofmanAuthored on Mar 29 2023, 04:49
bytesofmanPushed on Mar 30 2023, 18:33
Reviewer
Restricted Project
Differential Revision
D13494: [ecashaddrjs] Support returning hash160 as string instead of uint8array
Parents
rABCd43a2dc63e8a: [alias-server] Add alias-server to arc lint
Branches
Unknown
Tags
Unknown