ipld-bitcoin
0.3.0

Intro

Installable via npm install --save ipld-bitcoin, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save ipld-bitcoin

You can then require() ipld-bitcoin as normal:

const ipldBitcoin = require('ipld-bitcoin')

In the Browser

Ipld-bitcoin should work in any ES2015 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of ipld-bitcoin, including index.js and index.min.js, are included in the /dist folder. Ipld-bitcoin can also be found on unpkg.com under

resolve

Resolves a path within a Bitcoin block.

Returns the value or a link and the partial mising path. This way the IPLD Resolver can fetch the link and continue to resolve.

Parameters

  1. binaryBlob: Buffer:  
    Binary representation of a Bitcoin block
  2. path: string (='/'):  
    Path that should be resolved

Returns

Object result - Result of the path it it was resolved successfully
any result.value - Value the path resolves to
string result.remainderPath - If the path resolves half-way to a link, then the remainderPath is the part after the link that can be used for further resolving

tree

Return all available paths of a block.

Parameters

  1. binaryBlob: Buffer:  
    Binary representation of a Bitcoin block

serialize

Serialize internal representation into a binary Bitcoin block.

Parameters

  1. dagNode: BitcoinBlock:  
    Internal representation of a Bitcoin block

Returns

deserialize

Deserialize Bitcoin block into the internal representation.

Parameters

  1. binaryBlob: Buffer:  
    Binary representation of a Bitcoin block

Returns

BitcoinBlock

cid

Calculate the CID of the binary blob.

Parameters

  1. binaryBlob: Object:  
    Encoded IPLD Node
  2. userOptions: Object?:  
    Options to create the CID
  3. userOptions.cidVersion: number (=1):  
    CID version number

Returns

Promise<CID>