HomePhabricator

[ecash-lib] Improve address handling of ecash dev libraries

Description

[ecash-lib] Improve address handling of ecash dev libraries

Summary:
ecashaddrjs has limped and served well despite numerous legacy dependencies and an older structure. Aside from some maintenance headaches, this was acceptable and "good enough."

However, we would like to

  • Add more address lib features
  • Optionally support more address types
  • Reduce the use of third-party dependencies

In starting to reduce the use of third-party dependencies, it was discovered that basic hash methods available in ecash-lib after initWasm were needed to match existing ecashaddrjs functionality without third-party dependencies. It would not make sense to have ecashaddrjs work only if initWasm() were called in ecash-lib -- so we move the address functions to ecash-lib. Then, though, we still would like to not require the entire ecash-lib dependency for apps like chronik-client which barely use ecashaddrjs functionality.

Solution

  • Remove all dependencies from ecashaddrjs; this requires getting rid of toLegacy, which we add into ecash-lib
  • Breaking change version bump for ecashaddrjs to get rid of other technical debt (tree-shakeable exports so apps only pull in the functions they need, not the whole thing, and better typing, no more chronikReady param which confused typescript about return types)
  • New Address class in ecash-lib with full-featured address management
  • New legacyaddr.ts functions in ecash-lib for handling legacy addresses with zero deps (since we have hashing available in ecash-lib, and now also b58-ts with no deps)
  • Implement ecashaddrjs with breaking change in all monorepo apps

Test Plan:
npm test

docker build -f ecash-lib.Dockerfile -t ecash-lib_local . builds

Reviewers: #bitcoin_abc, emack, tobias_ruck

Reviewed By: #bitcoin_abc, emack, tobias_ruck

Subscribers: Fabien, tobias_ruck

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

Details

Provenance
bytesofmanAuthored on Dec 1 2024, 00:43
bytesofmanPushed on Thu, Dec 19, 23:55
Reviewer
Restricted Project
Differential Revision
D17269: [ecash-lib] Improve address handling of ecash dev libraries
Parents
rABC7f213483007a: Fix flakiness in tests that wait for peer info to update immediately after…
Branches
Unknown
Tags
Unknown