rpc

package
v0.0.0-...-faf87da Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: ISC Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrRPCDuplicateTx = -40
	ErrNoTxInfo       = -5
)

These error codes are defined in dcrd/dcrjson. They are copied here so we dont need to import the whole package.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller

type Caller interface {
	// String returns the dialed URL.
	String() string

	// 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 interface{}, args ...interface{}) error
}

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

type DcrdConnect

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

func SetupDcrd

func SetupDcrd(user, pass, addr string, cert []byte, params *chaincfg.Params, log slog.Logger) DcrdConnect

func (*DcrdConnect) BlockConnectedHandler

func (d *DcrdConnect) BlockConnectedHandler(blockConnected chan *wire.BlockHeader)

BlockConnectedHandler attaches a blockconnected notification handler to the dcrd client. Every time a notification is received, the header of the connected block is sent to the provided channel.

func (*DcrdConnect) Client

func (d *DcrdConnect) Client() (*DcrdRPC, string, error)

Client creates a new DcrdRPC client instance. Returns an error if dialing dcrd fails or if dcrd is misconfigured.

func (*DcrdConnect) Close

func (d *DcrdConnect) Close()

type DcrdRPC

type DcrdRPC struct {
	Caller
	// contains filtered or unexported fields
}

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

func (*DcrdRPC) ExistsLiveTicket

func (c *DcrdRPC) ExistsLiveTicket(ticketHash string) (bool, error)

ExistsLiveTicket uses existslivetickets RPC to check if the provided ticket hash is a live ticket known to the dcrd instance.

func (*DcrdRPC) GetBestBlockHeader

func (c *DcrdRPC) GetBestBlockHeader() (*dcrdtypes.GetBlockHeaderVerboseResult, error)

GetBestBlockHeader uses getbestblockhash RPC, followed by getblockheader RPC, to retrieve the header of the best block known to the dcrd instance.

func (*DcrdRPC) GetRawTransaction

func (c *DcrdRPC) GetRawTransaction(txHash string) (*dcrdtypes.TxRawResult, error)

GetRawTransaction uses getrawtransaction RPC to retrieve details about the transaction with the provided hash.

func (*DcrdRPC) IsDCP0010Active

func (c *DcrdRPC) IsDCP0010Active() (bool, error)

IsDCP0010Active uses getblockchaininfo RPC to determine if the DCP-0010 agenda has activated on the current network. DCP0010 is also known as "change subsidy split" agenda. it is not activated for EXCC and there is no plans to do so.

func (*DcrdRPC) NotifyBlocks

func (c *DcrdRPC) NotifyBlocks() error

NotifyBlocks uses notifyblocks RPC to request new block notifications from dcrd.

func (*DcrdRPC) SendRawTransaction

func (c *DcrdRPC) SendRawTransaction(txHex string) error

SendRawTransaction uses sendrawtransaction RPC to broadcast a transaction to the network. It ignores errors caused by duplicate transactions.

type WalletConnect

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

func SetupWallet

func SetupWallet(user, pass, addrs []string, cert [][]byte, params *chaincfg.Params, log slog.Logger) WalletConnect

func (*WalletConnect) Clients

func (w *WalletConnect) Clients() ([]*WalletRPC, []string)

Clients loops over each wallet and tries to establish a connection. It increments a count of failed connections if a connection cannot be established, or if the wallet is misconfigured.

func (*WalletConnect) Close

func (w *WalletConnect) Close()

type WalletRPC

type WalletRPC struct {
	Caller
	// contains filtered or unexported fields
}

WalletRPC provides methods for calling dcrwallet JSON-RPCs without exposing the details of JSON encoding.

func (*WalletRPC) AddTicketForVoting

func (c *WalletRPC) AddTicketForVoting(votingWIF, blockHash, txHex string) error

AddTicketForVoting uses importprivkey RPC, followed by addtransaction RPC, to add a new ticket to a voting wallet.

func (*WalletRPC) GetBestBlockHeight

func (c *WalletRPC) GetBestBlockHeight() (int64, error)

GetBestBlockHeight uses getblockcount RPC to query the height of the best block known by the dcrwallet instance.

func (*WalletRPC) RescanFrom

func (c *WalletRPC) RescanFrom(fromHeight int64) error

RescanFrom uses rescanwallet RPC to trigger the wallet to perform a rescan from the specified block height.

func (*WalletRPC) SetTSpendPolicy

func (c *WalletRPC) SetTSpendPolicy(tSpend, policy, ticket string) error

SetTSpendPolicy sets the specified tickets voting policy for a single tspend identified by its hash.

func (*WalletRPC) SetTreasuryPolicy

func (c *WalletRPC) SetTreasuryPolicy(key, policy, ticket string) error

SetTreasuryPolicy sets the specified tickets voting policy for all tspends published by the given treasury key.

func (*WalletRPC) SetVoteChoice

func (c *WalletRPC) SetVoteChoice(agenda, choice, ticketHash string) error

SetVoteChoice uses setvotechoice RPC to set the vote choice on the given agenda, for the given ticket.

func (*WalletRPC) TicketInfo

func (c *WalletRPC) TicketInfo(startHeight int64) (map[string]*wallettypes.TicketInfoResult, error)

TicketInfo uses ticketinfo RPC to retrieve a detailed list of all tickets known by this dcrwallet instance.

func (*WalletRPC) WalletInfo

func (c *WalletRPC) WalletInfo() (*wallettypes.WalletInfoResult, error)

WalletInfo uses walletinfo RPC to retrieve information about how the dcrwallet instance is configured.

Jump to

Keyboard shortcuts

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