A simple and beautiful bitcoin cash library of nodejs.
Simple syntax similar to bitbox/bchjs
lbox is just use libauth dependencies becase it is zero dependencies
you can extended the library to add new methods
npm i lbox
yarn add lbox
lbox.Address.toLegacyAddress(
"bitcoincash:qzm47qz5ue99y9yl4aca7jnz7dwgdenl85jkfx3znl"
);
let decoded;
let type;
if (cashAddress.split(":").length == 2) {
// decode Address with prefix
decoded = libauth.decodeCashAddress(cashAddress);
if (typeof decoded != "object") throw new Error(decoded);
type = libauth.CashAddressType[decoded.type].toLocaleLowerCase();
} else {
decoded = libauth.decodeCashAddressFormatWithoutPrefix(cashAddress);
if (typeof decoded != "object") throw new Error(decoded);
type = libauth.CashAddressType[decoded.version].toLocaleLowerCase();
}
// check if Address from test net
type = decoded.prefix == "bitcoincash" ? type : type + "-testnet";
libauth.encodeBase58Address(this.instantiateSha256, type, decoded.hash);