npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

icellan-shapeshifter.js

v0.1.1

Published

Shapeshifter.js lets you quickly and simply switch between Bitcoin transaction formats.

Downloads

5

Readme

Shapeshifter.js

Shapeshifter lets you quickly and simply switch between Bitcoin transaction formats

npm License Build Status

Shapeshifter.js is a JavaScript library for switching between Bitcoin transaction formats. Quickly and simply shift between raw tx formats, structured BSV Tx objects, and TXO and BOB serialization formats.

Please NOTE

This is a severely limited version of Shapeshifter, working on bsv lib v1.5.3. It is only meant to transform raw transactions to BOB or TXO format. It cannot transform them back like the full version of this library can.

Installation

Install Shapeshifter with npm or yarn:

npm install @libitx/shapeshifter.js
# or
yarn add @libitx/shapeshifter.js

Alternatively use in a browser via CDN:

<script src="//unpkg.com/@libitx/shapeshifter.js/dist/shapeshifter.min.js"></script>

Shapeshifter has a peer dependency on version 2 the bsv library which must also be installed in your project.

Usage

Using Shapeshifter.js couldn't be simpler. Under the hood Shapeshifter automatically determines the source format, so all you need to do is pass a transaction object of any format to the appropriate function of the format you want to convert to (from: toHex(), toBuffer(), toTx(), toTxo() or toBob()).

// Convert to raw hex
Shapeshifter.toHex(tx)
// => "01000000..."

// Convert to raw Buffer
Shapeshifter.toBuffer(tx)
// => <Buffer 01 00 00 00 ...>

// Convert to structured BSV Tx object
Shapeshifter.toTx(tx)
// => Tx { versionBytesNum: 1, txIns: [...], txOuts: [...], ... }

// Convert to TXO map
Shapeshifter.toTxo(tx)
// => {in: [...], out: [...], ...}

// Convert to BOB map
Shapeshifter.toBob(tx)
// => {in: [...], out: [...], ...}

Shapeshifter.js can also be used to convert individual inputs and outputs between the supported formats.

To see Shapeshifter in action, try the live demo.

Gotcha - watch those "f" attributes

The modern Bitbus and Bitsocket services return an "f" attribute in both BOB and TXO schemas where the script chunk is in excess of 512 bytes. If converting between BOB and TXO the "f" is kept in place, but if converting back to raw or a BSV TxIn instance, the "f" attribute is ignored, meaning you will not get the same transaction.

If you wish to convert a BOB or TXO object which contains "f" attributes back to a raw transaction, you must first fetch the referenced data from BitFS and attach it to the same cell or indexed attribute as a "b" or "h" attribute.

Example:

// Src object
{
  "f4": "ed661719089cab4be7dbeea527ffe40238d7d714e1dce5db2e2d75c8c2d1fd68.o.1.4",
  ...
}

// Must be converted to
{
  "b4": "TXkgZGVhciBXb3Jtd29vZCwgCgpJdCB3YXJtcyBteSBoZWFydCB0aGF0IHlvdSBo...",
  ...
}

License

Shapeshifter.js is open source and released under the Apache-2 License.

© Copyright 2020 libitx.