node

package
v0.0.0-...-891ff74 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Hash           types.Bytes   `json:"hash"`
	PrevBlockHash  types.Bytes   `json:"previousblockhash"`
	Height         int32         `json:"height"`
	Weight         int32         `json:"weight"`
	Size           int64         `json:"size"`
	Version        int32         `json:"version"`
	HashMerkleRoot types.Bytes   `json:"merkleRoot"`
	WitnessRoot    types.Bytes   `json:"witnessRoot"`
	TreeRoot       types.Bytes   `json:"treeRoot"`
	ReservedRoot   types.Bytes   `json:"reservedRoot"`
	Mask           types.Bytes   `json:"mask"`
	Time           int32         `json:"time"`
	Bits           types.Bytes   `json:"bits"`
	Difficulty     float64       `json:"difficulty"`
	Chainwork      types.Bytes   `json:"chainwork"`
	Nonce          int64         `json:"nonce"`
	ExtraNonce     types.Bytes   `json:"extraNonce"`
	Transactions   []Transaction `json:"tx"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(origin, apiKey string) *Client

func (*Client) GetBlockByHeight

func (client *Client) GetBlockByHeight(ctx context.Context, height int32) (*Block, error)

func (*Client) GetBlockHashByHeight

func (client *Client) GetBlockHashByHeight(ctx context.Context, height int32) (types.Bytes, error)

func (*Client) GetBlocksHeight

func (client *Client) GetBlocksHeight(ctx context.Context) (int32, error)

func (*Client) GetInfo

func (client *Client) GetInfo(ctx context.Context, height int32) (*Block, error)

func (*Client) GetMempool

func (client *Client) GetMempool(ctx context.Context) ([]SingleTransaction, error)

func (*Client) GetTxByTxid

func (client *Client) GetTxByTxid(ctx context.Context, txid string) (*SingleTransaction, error)

type MyAddress

type MyAddress struct {
	String string
}

type SingleTransaction

type SingleTransaction struct {
	Txid       types.Bytes      `json:"hash"`
	WitnessTx  types.Bytes      `json:"witnessHash"`
	Fee        int64            `json:"fee"`
	Rate       int64            `json:"rate"`
	BlockHash  types.Bytes      `json:"blockHash"`
	IndexBlock int32            `json:"index"`
	Version    int32            `json:"version"`
	Locktime   int64            `json:"locktime"`
	Size       int64            `json:"size"`
	TxInputs   []SingleTxInput  `json:"inputs"`
	TxOutputs  []SingleTxOutput `json:"outputs"`
}

there is a need for additonal type, because the default node field names are different in different methods

type SingleTxInput

type SingleTxInput struct {
	MyHashPrevout struct {
		Hash         types.Bytes `json:"hash"`
		IndexPrevout int64       `json:"index"`
	} `json:"prevout"`
	Sequence int64 `json:"sequence"`
}

func (*SingleTxInput) HashPrevout

func (txInput *SingleTxInput) HashPrevout() types.Bytes

type SingleTxOutput

type SingleTxOutput struct {
	Index     int32       `json:"n"`
	Value     types.Money `json:"value"`
	MyAddress string      `json:"address"`
	Covenant  struct {
		CovenantAction string        `json:"action"`
		CovenantItems  []types.Bytes `json:"items"`
	} `json:"covenant"`
}

type Transaction

type Transaction struct {
	Txid       types.Bytes `json:"txid"`
	WitnessTx  types.Bytes `json:"hash"`
	Fee        int64       `json:"fee"`
	Rate       int64       `json:"rate"`
	BlockHash  types.Bytes `json:"blockHash"`
	IndexBlock int32       `json:"index"`
	Version    int32       `json:"version"`
	Locktime   int64       `json:"locktime"`
	Size       int64       `json:"size"`
	TxInputs   []TxInput   `json:"vin"`
	TxOutputs  []TxOutput  `json:"vout"`
}

type TxInput

type TxInput struct {
	HashPrevout  types.Bytes `json:"txid"`
	IndexPrevout int64       `json:"vout"`
	Sequence     int64       `json:"sequence"`
}

type TxOutput

type TxOutput struct {
	Index     int32       `json:"n"`
	Value     types.Money `json:"value"`
	MyAddress struct {
		String string `json:"string"`
	} `json:"address"`
	Covenant struct {
		CovenantAction string        `json:"action"`
		CovenantItems  []types.Bytes `json:"items"`
	} `json:"covenant"`
}

func (*TxOutput) Address

func (txOutput *TxOutput) Address() string

Jump to

Keyboard shortcuts

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