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.
The way js deps work, users who need only the address functions from ecash-lib will end up only installing those in the published version of their app. Users who want legacy ecashaddrjs features without dealing with initWasm may use the legacy ecashaddrjs, though it will be deprecated.
What this diff does
- Match the functionality of ecashaddrjs but with no third-party dependencies (well, one dev-dependency for generating random hashes...we could lose it but it is useful to show we pass the same tests as the old lib)
- Replace ecashaddrjs with now-local functions in ecash-lib
- Update ecash-lib dockerfile to account for change
- Update CI to account for everything that uses ecash-lib now needing b58-ts
Breaking changes when migrating from ecashaddrjs to ecash-lib
When I first started adding functionality to ecashaddrjs, I was hesitant to introduce any breaking changes. This led to a bunch of baggage. In this version,
- We only support lowercase address types i.e. p2pkh or p2sh, as this is what ChronikClient supports
- We store hash as a string. ecash-lib offers fromHex method to trivially convert this to a Uint8Array. But the string is also what ChronikClient expects and what most of my apps expect. Just picking one greatly enhances the effectiveness of typescript with these address methods. I considered storing both formats -- but that gets complicated as many helper functions also work with hash as a string.
- We no longer validate against a small whitelist of accepted prefixes. We will encode any prefix.
- We no longer decode prefixless addresses against a whitelist of accepted prefixes. We decode prefixless addresses against ecash prefix only.
Going forward, will replace ecashaddrjs with ecash-lib methods everywhere.