ipldbtc

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 11 Imported by: 0

README

Bitcoin ipld format

Coverage Status Travis CI

An ipld codec for Bitcoin blocks and transactions allowing path traversals across the blockchain!

Note: This is WIP and may not be an entirely correct parser.

Table of Contents

Install

go get github.com/ipfs/go-ipld-btc

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBlockMessage

func DecodeBlockMessage(b []byte) ([]node.Node, error)

func DecodeMaybeTx

func DecodeMaybeTx(b []byte) (node.Node, error)

Types

type Block

type Block struct {
	Version    uint32  `json:"version"`
	Parent     cid.Cid `json:"parent"`
	MerkleRoot cid.Cid `json:"tx"`
	Timestamp  uint32  `json:"timestamp"`
	Difficulty uint32  `json:"difficulty"`
	Nonce      uint32  `json:"nonce"`
	// contains filtered or unexported fields
}

func DecodeBlock

func DecodeBlock(b []byte) (*Block, error)

func ReadBlock

func ReadBlock(r *bufio.Reader) (*Block, error)

func (*Block) BTCSha

func (b *Block) BTCSha() []byte

func (*Block) Cid

func (b *Block) Cid() cid.Cid

func (*Block) Copy

func (b *Block) Copy() node.Node

func (*Block) HexHash

func (b *Block) HexHash() string
func (b *Block) Links() []*node.Link

func (*Block) Loggable

func (b *Block) Loggable() map[string]interface{}

func (*Block) RawData

func (b *Block) RawData() []byte

func (*Block) Resolve

func (b *Block) Resolve(path []string) (interface{}, []string, error)

Resolve attempts to traverse a path through this block.

func (b *Block) ResolveLink(path []string) (*node.Link, []string, error)

ResolveLink is a helper function that allows easier traversal of links through blocks

func (*Block) Size

func (b *Block) Size() (uint64, error)

func (*Block) Stat

func (b *Block) Stat() (*node.NodeStat, error)

func (*Block) String

func (b *Block) String() string

func (*Block) Tree

func (b *Block) Tree(p string, depth int) []string
type Link struct {
	Target cid.Cid
}

type Tx

type Tx struct {
	Version   uint32     `json:"version"`
	Inputs    []*TxIn    `json:"inputs"`
	Outputs   []*TxOut   `json:"outputs"`
	LockTime  uint32     `json:"locktime"`
	Witnesses []*Witness `json:"witnesses"`
}

func DecodeTx

func DecodeTx(b []byte) (*Tx, error)

func (*Tx) BTCSha

func (t *Tx) BTCSha() []byte

func (*Tx) Cid

func (t *Tx) Cid() cid.Cid

func (*Tx) Copy

func (t *Tx) Copy() node.Node

func (*Tx) HexHash

func (t *Tx) HexHash() string
func (t *Tx) Links() []*node.Link

func (*Tx) Loggable

func (t *Tx) Loggable() map[string]interface{}

func (*Tx) RawData

func (t *Tx) RawData() []byte

func (*Tx) Resolve

func (t *Tx) Resolve(path []string) (interface{}, []string, error)
func (t *Tx) ResolveLink(path []string) (*node.Link, []string, error)

func (*Tx) Size

func (t *Tx) Size() (uint64, error)

func (*Tx) Stat

func (t *Tx) Stat() (*node.NodeStat, error)

func (*Tx) String

func (t *Tx) String() string

func (*Tx) Tree

func (t *Tx) Tree(p string, depth int) []string

type TxIn

type TxIn struct {
	PrevTx      cid.Cid `json:"txid,omitempty"`
	PrevTxIndex uint32  `json:"vout"`
	Script      []byte  `json:"script"`
	SeqNo       uint32  `json:"sequence"`
}

func (*TxIn) WriteTo

func (i *TxIn) WriteTo(w io.Writer) (int64, error)

type TxOut

type TxOut struct {
	Value  uint64 `json:"value"`
	Script []byte `json:"script"`
}

func (*TxOut) WriteTo

func (o *TxOut) WriteTo(w io.Writer) (int64, error)

type TxTree

type TxTree struct {
	Left  *node.Link
	Right *node.Link
}

func DecodeTxTree

func DecodeTxTree(b []byte) (*TxTree, error)

func (*TxTree) BTCSha

func (t *TxTree) BTCSha() []byte

func (*TxTree) Cid

func (t *TxTree) Cid() cid.Cid

func (*TxTree) Copy

func (t *TxTree) Copy() node.Node
func (t *TxTree) Links() []*node.Link

func (*TxTree) Loggable

func (t *TxTree) Loggable() map[string]interface{}

func (*TxTree) MarshalJSON

func (t *TxTree) MarshalJSON() ([]byte, error)

func (*TxTree) RawData

func (t *TxTree) RawData() []byte

func (*TxTree) Resolve

func (t *TxTree) Resolve(path []string) (interface{}, []string, error)
func (t *TxTree) ResolveLink(path []string) (*node.Link, []string, error)

func (*TxTree) Size

func (t *TxTree) Size() (uint64, error)

func (*TxTree) Stat

func (t *TxTree) Stat() (*node.NodeStat, error)

func (*TxTree) String

func (t *TxTree) String() string

func (*TxTree) Tree

func (t *TxTree) Tree(p string, depth int) []string

type Witness

type Witness struct {
	Data [][]byte `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL