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 unkpkg.com under
ResolveCallback
Parameters
error: Error?
:Error if path can't be resolved
resolve
Resolves a path in 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
binaryBlob: Buffer
:Binary representation of a Bitcoin blockpath: string (='/')
:Path that should be resolvedcallback: ResolveCallback
:Callback that handles the return value
Returns
void
tree
Return all available paths of a block.
Parameters
binaryBlob: Buffer
:Binary representation of a Bitcoin blockoptions: Object?
:Possible optionsoptions.values: boolean (=false)
:Retun only the paths by default. If it istrue
also return the valuescallback: TreeCallback
:Callback that handles the return value
Returns
void
serialize
Serialize internal representation into a binary Bitcoin block.
Parameters
dagNode: BitcoinBlock
:Internal representation of a Bitcoin blockcallback: SerializeCallback
:Callback that handles the return value
Returns
void
DeserializeCallback
Parameters
error: Error?
:Error if deserialization faileddagNode: BitcoinBlock?
:Internal representation of a Bitcoin block if deserialization was successful
deserialize
Deserialize Bitcoin block into the internal representation,
Parameters
binaryBlob: Buffer
:Binary representation of a Bitcoin blockcallback: DeserializeCallback
:Callback that handles the return value
Returns
void
CidCallback
Parameters
error: Error?
:Error if getting the CID failedcid: CID?
:CID if call was successful
cid
Get the CID of the DAG-Node.
Parameters
dagNode: BitcoinBlock
:Internal representation of a Bitcoin blockoptions: Object?
:Options to create the CIDoptions.version: number (=1)
:CID version numberoptions.hashAlg: string (='dbl-sha2-256')
:Hashing algorithmcallback: CidCallback
:Callback that handles the return value
Returns
void