node

package
v0.0.0-...-7abacdd Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Unlicense Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const RPCAddress = "0.0.0.0:8338"

RPCAddress where the node will be listening for rpc calls.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetTransactionResponse

type GetTransactionResponse struct {
	Tx    tx.Tx
	Block block.Block
}

GetTransactionResponse is the structure of the GetTransaction rpc call response.

type Node

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

Node represents a Bitcoin Node.

func New

func New(hostAddr string, seedNodes []string, miner bool) (*Node, error)

New creates a new node.

func (*Node) AddNode

func (n *Node) AddNode(address string, reply *int) error

AddNode adds a node to the peer list.

func (*Node) Close

func (n *Node) Close(listeners ...net.Listener) error

Close releases the resources associated to a node.

func (*Node) DisconnectNode

func (n *Node) DisconnectNode(address string, reply *int) error

DisconnectNode removes a node from the peer list.

func (*Node) GetAddressUTXOs

func (n *Node) GetAddressUTXOs(address string, reply *[]tx.Output) error

GetAddressUTXOs returns the UTXOs corresponding to an address.

func (*Node) GetAddressesUTXOs

func (n *Node) GetAddressesUTXOs(addresses []string, reply *map[string][]tx.Output) error

GetAddressesUTXOs returns the UTXOs corresponding to a set of addresses.

func (*Node) GetBestHeight

func (n *Node) GetBestHeight(_ struct{}, reply *int32) error

GetBestHeight returns the node's blockchain best height.

func (*Node) GetBlock

func (n *Node) GetBlock(hash []byte, reply *block.Block) error

GetBlock returns a block given a hash.

func (*Node) GetLastBlock

func (n *Node) GetLastBlock(_ struct{}, reply *block.Block) error

GetLastBlock returns the last block (tip) of a chain.

func (*Node) GetPeerInfo

func (n *Node) GetPeerInfo(_ struct{}, reply *[]string) error

GetPeerInfo returns data about each connected node.

func (*Node) GetRawMempool

func (n *Node) GetRawMempool(_ struct{}, reply *[]string) error

GetRawMempool returns the node's mempool transaction ids.

func (*Node) GetTransaction

func (n *Node) GetTransaction(id []byte, reply *GetTransactionResponse) error

GetTransaction returns a transaction given an id.

func (*Node) ListBlocks

func (n *Node) ListBlocks(_ struct{}, reply *[]block.Block) error

ListBlocks returns all the blocks from the blockchain.

func (*Node) Run

func (n *Node) Run(accountName string) error

Run starts the execution of the node.

func (*Node) RunRPCServer

func (n *Node) RunRPCServer() (net.Listener, error)

RunRPCServer starts the node's rpc server.

The listener is returned to call Close when done.

func (*Node) SendPing

func (n *Node) SendPing(_ struct{}, reply *struct{}) error

SendPing sends a ping request to all the other peers.

func (*Node) SendTx

func (n *Node) SendTx(params SendTxParams, reply *[]byte) error

SendTx sends sends a transaction to another node and returns the transaction id.

func (*Node) Stop

func (n *Node) Stop(_ struct{}, reply *struct{}) error

Stop stops the running node.

type SendTxParams

type SendTxParams struct {
	AccountName string
	To          string
	Amount      int
	Fee         int
}

SendTxParams contains the parameters used for the SendTx rpc call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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