Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cashaddr

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cashaddr

Bitcoin Cash CashAddr

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-97.73%
Maintainers
2
Weekly downloads
 
Created
Source

cashaddr

This is a JavaScript implementation for the CashAddr address format used in Bitcoin Cash. It serves as a glue to integrate the @scure/btc-signer library with Bitcoin Cash.

This library depends on and is heavily coupled with the @scure/base and @scure/btc-signer libraries.

Installation

npm install cashaddr

Usage

import { Address, NETWORK } from 'cashaddr';
import { hex } from '@scure/base';

const hash = hex.decode('f5bf48b397dae70be82b3cca4793f8eb2b6cdac9');

const address = Address(NETWORK).encode({
  format: 'cashaddr',
  type: 'pkh',
  hash,
});
console.log(address);
// bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2

const decoded = Address(NETWORK).decode('bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2');
console.log(decoded);
// { type: 'pkh', hash: Uint8Array(20) [...], format: 'cashaddr' }

const legacy = Address(NETWORK).encode({
  format: 'legacy',
  type: 'pkh',
  hash,
});
console.log(legacy);
// 1PQPheJQSauxRPTxzNMUco1XmoCyPoEJCp

const converted = Address(NETWORK).toCashAddress('1PQPheJQSauxRPTxzNMUco1XmoCyPoEJCp');
console.log(converted);
// bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2

License

MIT

Keywords

FAQs

Package last updated on 21 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc