dcrd

package
v5.0.0-...-2e8bb31 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockConnected

func BlockConnected(params json.RawMessage) (header *wire.BlockHeader, relevant []*wire.MsgTx, err error)

BlockConnected extracts the parameters from a blockconnected JSON-RPC notification.

func MixMessage

func MixMessage(params json.RawMessage) (msg mixing.Message, err error)

MixMessage extracts the mixing message from a mixmessage JSON-RPC notification.

func RelevantTxAccepted

func RelevantTxAccepted(params json.RawMessage) (tx *wire.MsgTx, err error)

RelevantTxAccepted extracts the parameters from a relevanttxaccepted JSON-RPC notification.

func TSpend

func TSpend(params json.RawMessage) (tx *wire.MsgTx, err error)

TSpend extracts the parameters from a tspend JSON-RPC notification.

func WinningTickets

func WinningTickets(params json.RawMessage) (block *chainhash.Hash, height int32, winners []*chainhash.Hash, err error)

WinningTickets extracts the parameters from a winningtickets JSON-RPC notification.

Types

type Caller

type Caller interface {
	// Call performs the remote procedure call defined by method and
	// waits for a response or a broken client connection.
	// Args provides positional parameters for the call.
	// Res must be a pointer to a struct, slice, or map type to unmarshal
	// a result (if any), or nil if no result is needed.
	Call(ctx context.Context, method string, res any, args ...any) error
}

Caller provides a client interface to perform JSON-RPC remote procedure calls.

type RPC

type RPC struct {
	Caller
}

RPC provides methods for calling dcrd JSON-RPCs without exposing the details of JSON encoding.

func New

func New(caller Caller) *RPC

New creates a new RPC client instance from a caller.

func (*RPC) Blocks

func (r *RPC) Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error)

Blocks returns the blocks for each block hash.

func (*RPC) CFilterV2

func (r *RPC) CFilterV2(ctx context.Context, blockHash *chainhash.Hash) (*gcs.FilterV2, uint32, []chainhash.Hash, error)

CFilterV2 returns the version 2 committed filter and the data required for verifying the inclusion proof of the cfilter for a block.

func (*RPC) CFiltersV2

func (r *RPC) CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash) ([]filterProof, error)

CFiltersV2 returns the version 2 committed filters for blocks. If this method errors, a partial result of filter proofs may be returned, with nil filters if the query errored.

func (*RPC) ExistsLiveTicket

func (r *RPC) ExistsLiveTicket(ctx context.Context, ticket *chainhash.Hash) (bool, error)

ExistsLiveTicket returns whether a ticket identified by its hash is currently live and not immature.

func (*RPC) ExistsLiveTickets

func (r *RPC) ExistsLiveTickets(ctx context.Context, tickets []*chainhash.Hash) (bitset.Bytes, error)

ExistsLiveTickets returns a bitset identifying whether each ticket is currently live.

func (*RPC) GetBlockchainInfo

func (r *RPC) GetBlockchainInfo(ctx context.Context) (*dcrdtypes.GetBlockChainInfoResult, error)

GetBlockchainInfo returns information about the underlying dcrd node.

func (*RPC) GetConfirmationHeight

func (r *RPC) GetConfirmationHeight(ctx context.Context, txHash *chainhash.Hash) (int32, error)

GetConfirmationHeight returns the block height of a transaction that has been mined in the mainchain of the underlying node.

NOTE: this requires the node to be running with the transaction index enabled, otherwise it will error.

func (*RPC) GetMempoolTSpends

func (r *RPC) GetMempoolTSpends(ctx context.Context) ([]*wire.MsgTx, error)

GetMempoolTSpends retrieves all mempool tspends.

func (*RPC) GetTxOut

func (r *RPC) GetTxOut(ctx context.Context, txHash *chainhash.Hash, index uint32, tree int8, includeMempool bool) (*dcrdtypes.GetTxOutResult, error)

GetTxOut returns information about a transaction output as of the current mainchain tip of the underlying node.

NOTE: this returns a nil value with nil error if the output is not known or has already been spent.

func (*RPC) Headers

func (r *RPC) Headers(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error)

Headers returns the block headers starting at the fork point between the client and the dcrd server identified by the client's block locators.

func (*RPC) LoadTxFilter

func (r *RPC) LoadTxFilter(ctx context.Context, reload bool, addrs []stdaddr.Address, outpoints []wire.OutPoint) error

LoadTxFilter loads or reloads the precise server-side transaction filter used for relevant transaction notifications and rescans. Addresses and outpoints are added to an existing filter if reload is false.

func (*RPC) MempoolCount

func (r *RPC) MempoolCount(ctx context.Context, kind string) (int, error)

MempoolCount returns the count of a particular kind of transaction in mempool. Kind may be one of:

"all"
"regular"
"tickets"
"votes"
"revocations"

func (*RPC) MixMessage

func (r *RPC) MixMessage(ctx context.Context, hash *chainhash.Hash) (mixing.Message, error)

MixMessage queries the dcrd mixpool for a mixing message by its hash.

func (*RPC) MixPairRequests

func (r *RPC) MixPairRequests(ctx context.Context) ([]*wire.MsgMixPairReq, error)

MixPairRequests returns all mixing pair request messages currently held by the dcrd mixpool.

func (*RPC) PublishMixMessages

func (r *RPC) PublishMixMessages(ctx context.Context, msgs ...mixing.Message) error

PublishMixMessages submits each mixing message to the dcrd mixpool for acceptance. If accepted, the messages are published to other peers.

func (*RPC) PublishTransaction

func (r *RPC) PublishTransaction(ctx context.Context, tx *wire.MsgTx) error

PublishTransaction submits the transaction to dcrd mempool for acceptance. If accepted, the transaction is published to other peers. The transaction may not be an orphan.

func (*RPC) PublishTransactions

func (r *RPC) PublishTransactions(ctx context.Context, txs ...*wire.MsgTx) error

PublishTransactions submits each transaction to dcrd mempool for acceptance. If accepted, the transaction is published to other peers. Transactions are sent in order and later transactions may spend outputs of previous transactions. No transaction may be an orphan.

func (*RPC) Rescan

func (r *RPC) Rescan(ctx context.Context, blocks []chainhash.Hash, save func(block *chainhash.Hash, txs []*wire.MsgTx) error) error

Rescan rescans the specified blocks in order, using the loaded transaction filter to determine which transactions are possibly relevant to the client. The save function is called for the discovered transactions from each block.

func (*RPC) StakeDifficulty

func (r *RPC) StakeDifficulty(ctx context.Context) (dcrutil.Amount, error)

StakeDifficulty returns the stake difficulty (AKA ticket price) of the next block.

func (*RPC) String

func (r *RPC) String() string

String returns a string representation of the caller (if it exists).

func (*RPC) UsedAddresses

func (r *RPC) UsedAddresses(ctx context.Context, addrs []stdaddr.Address) (bitset.Bytes, error)

UsedAddresses returns a bitset identifying whether each address has been publically used on the blockchain. This feature requires the optional dcrd existsaddress index to be enabled.

Jump to

Keyboard shortcuts

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