🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

bip136

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bip136

A javascript library for encoding and decoding BIP136 TxRefs

1.0.2
latest
Source
npm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

bip136js

GitHub Actions Build Coverage Security Rating Reliability Rating Maintainability RatingLines of Code Socket Badge License: ISC

A javascript library for encoding and decoding BIP 136 TxRefs. This package passes all test cases from the spec.

This library goes beyond the spec to attempt to decode TxRefs that have had the Human-Readable Part (HRP) stripped off but are otherwise valid.

Installation

npm i bip136

Usage

import * as bip136 from 'bip136';

// decodes TxRefs with separators
bip136.decode('tx1:r29u-mqjx-putt-3p0');
// { network: 'mainnet', blockHeight: 456789, txIndex: 1234 }

// decodes TxRefs without separators
bip136.decode('TX1R29UMQJXPUTT3P0');
// { network: 'mainnet', blockHeight: 456789, txIndex: 1234 }

// decodes TxRefs with invalid characters
bip136.decode('tx1!r29u/mqj*x-putt^^3p0');
// { network: 'mainnet', blockHeight: 456789, txIndex: 1234 }

// decodes TxRefs with outpoints
bip136.decode('tx1:y7ll-llll-lpqq-s4qz-hw');
// { network: 'mainnet', blockHeight: 16777215, txIndex: 32767, outpoint: 1 }

// decodes TxRefs with the HRP stripped off
bip136.decode('xz8e-kyyp-qmff-zyt');
// { network: 'testnet', blockHeight: 2470513, txIndex: 36 }

// encodes TxRefs
bip136.encode({
  blockHeight: 709635,
  txIndex: 60,
});
// 'tx1:rxq2-tpup-q0nd-lah'

Keywords

bip136

FAQs

Package last updated on 23 Aug 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