Skip to content

libitx/shapeshifter

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Shapeshifter

Shapeshifter lets you quickly and simply switch between Bitcoin transaction formats

Hex.pm GitHub Build Status

Shapeshifter is an Elixir library for switching between Bitcoin transaction formats. Quickly and simply shift between raw tx binaries, BSV.Tx structs, and TXO and BOB transaction formats.

Sponsors

Supported by:

Coingeek

Your sponsorship will help us continue to release and maintain software that Bitcoin businesses and developers depend on.

๐Ÿ‘‰ Sponsor Chronos Labs' open source work

Installation

The package can be installed by adding shapeshifter to your list of dependencies in mix.exs:

def deps do
  [
    {:shapeshifter, "~> 0.2"}
  ]
end

Usage

Using Shapeshifter couldn't be simpler. Under the hood Shapeshifter uses pattern matching to automatically determine 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: to_raw/2, to_tx/1, to_txo/1 or to_bob/1).

# Convert to raw tx
Shapeshifter.to_raw(tx)
# => <<1, 0, 0, 0, ...>>

# Convert to raw tx with hex encoding
Shapeshifter.to_raw(tx, encoding: :hex)
# => "01000000..."

# Convert to BSV.Tx struct
Shapeshifter.to_tx(tx)
# => %BSV.Tx{}

# Convert to TXO map
Shapeshifter.to_txo(tx)
# => %{"in" => [...], "out" => [...], ...}

# Convert to BOB map
Shapeshifter.to_bob(tx)
# => %{"in" => [...], "out" => [...], ...}

For more advanced use, Shapeshifter can also be used to convert individual inputs and outputs between the supported formats.

For more examples, refer to the full documentation.

License

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

ยฉ Copyright 2020-2021 Chronos Labs Ltd.

About

Shapeshifter is an Elixir library for switching between Bitcoin transaction formats.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages