bech32cashaddr
v1.0.0
Published
Bech32 CashAddr encoding
Maintainers
Readme
Bech32 CashAddr
This project implements the base encoding used by CashAddr, the modified version of Bech32 described in the Bitcoin Cash specification. It focuses on the generic encoding layer: converting between the human-readable part, base32 payload, and checksum without any coin-specific version byte logic.
Specification: https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md
Install
npm i bech32cashaddrUsage
import { cashaddr } from 'bech32cashaddr';
const prefix = 'bitcoincash';
const data = Uint8Array.of(
0, 1, 2, 3, 4,
5, 6, 7, 8, 9
);
const words = cashaddr.toWords(data);
const encoded = cashaddr.encode(prefix, words);
console.log(encoded); // bitcoincash:qqqsyqcyq5rqwzqf50xhu6j9
const decoded = cashaddr.decode(encoded);
console.log(decoded.prefix); // bitcoincash
console.log(cashaddr.fromWords(decoded.words)); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]License
MIT
