Skip to content

Latest commit

 

History

History
88 lines (70 loc) · 1.85 KB

File metadata and controls

88 lines (70 loc) · 1.85 KB
home true
heroText Lbox.js
heroImage /logo.svg
tagline A simple and beautiful bitcoin cash nodejs library.
bgImageStyle
height
450px
isShowTitleInHome true
actionText Guide
actionLink /docs/
features
title details
Easy
Simple syntax similar to bitbox/bchjs
title details
Dependencies
Lbox just uses libauth as dependency because it has zero dependencies
title details
Extended
You can extended the library to add new methods

install

npm i lbox
yarn add lbox

lbox vs libauth syntax

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);

support

BCH

bitcoincash:qqqxpdhdu8umgzr9adzfvypdu65xqtejtq9nssqyww