Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/libitx/shapeshifter
Shapeshifter is an Elixir library for switching between Bitcoin transaction formats.
https://github.com/libitx/shapeshifter
bitcoin bsv elixir
Last synced: 2 months ago
JSON representation
Shapeshifter is an Elixir library for switching between Bitcoin transaction formats.
- Host: GitHub
- URL: https://github.com/libitx/shapeshifter
- Owner: libitx
- License: apache-2.0
- Created: 2020-08-08T22:18:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-23T14:49:52.000Z (about 3 years ago)
- Last Synced: 2024-04-24T01:21:20.958Z (9 months ago)
- Topics: bitcoin, bsv, elixir
- Language: Elixir
- Homepage:
- Size: 159 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shapeshifter
![Shapeshifter lets you quickly and simply switch between Bitcoin transaction formats](https://github.com/libitx/shapeshifter/raw/master/media/poster.png)
![Hex.pm](https://img.shields.io/hexpm/v/shapeshifter?color=informational)
![GitHub](https://img.shields.io/github/license/libitx/shapeshifter?color=informational)
![Build Status](https://img.shields.io/github/workflow/status/libitx/shapeshifter/Elixir%20CI)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:
Your sponsorship will help us continue to release and maintain software that Bitcoin businesses and developers depend on.
#### 👉 [Sponsor Chronos Labs' open source work](https://www.chronoslabs.net/sponsor/)
## Installation
The package can be installed by adding `shapeshifter` to your list of dependencies in `mix.exs`:
```elixir
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`).
```elixir
# 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](https://hexdocs.pm/shapeshifter).
## License
Shapeshifter is open source and released under the [Apache-2 License](https://github.com/libitx/shapeshifter/blob/master/LICENSE).
© Copyright 2020-2021 Chronos Labs Ltd.