rpc

package
v0.0.0-...-910450c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package rpc provides a client that's able to communicate with a `monerod` daemon via its RPC interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHTTPClient

func WithHTTPClient(v *http.Client) func(o *clientOptions)

WithHTTPClient is a functional option for providing a custom HTTP client to be used for the HTTP requests made to a monero daemon.

Types

type Client

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

Client is a wrapper over a plain HTTP client providing methods that correspond to all RPC invocations to a `monerod` daemon, including restricted and non-restricted ones.

func NewClient

func NewClient(address string, opts ...ClientOption) (*Client, error)

NewClient instantiates a new Client that is able to communicate with monerod's RPC endpoints.

The `address` might be either restricted (typically <ip>:18089) or not (typically <ip>:18081).

func (*Client) JSONRPC

func (c *Client) JSONRPC(ctx context.Context, method string, params interface{}, response interface{}) error

JSONRPC issues a request for a particular method under the JSONRPC endpoint with the proper envolope for its requests and unwrapping of results for responses.

func (*Client) RawBinaryRequest

func (c *Client) RawBinaryRequest(ctx context.Context, endpoint string, body io.Reader) (io.ReadCloser, error)

RawBinaryRequest makes requests to any endpoints, not assuming any particular format.

func (*Client) RawRequest

func (c *Client) RawRequest(ctx context.Context, endpoint string, params interface{}, response interface{}) error

RawRequest makes requests to any endpoints, not assuming any particular format except of response is JSON.

type ClientOption

type ClientOption func(o *clientOptions)

ClientOption defines a functional option for overriding optional client configuration parameters.

type RequestEnvelope

type RequestEnvelope struct {
	ID      string      `json:"id"`
	JSONRPC string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
}

RequestEnvelope wraps all requests made to the RPC server.

type ResponseEnvelope

type ResponseEnvelope struct {
	ID      string      `json:"id"`
	JSONRPC string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	Error   struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error,omitempty"`
}

ResponseEnvelope wraps all responses from the RPC server.

Directories

Path Synopsis
Package daemon provides a client that encapsulates RPC methods and endpoints that can be hit in a daemon.
Package daemon provides a client that encapsulates RPC methods and endpoints that can be hit in a daemon.
Package wallet provides a client that encapsulates RPC methods that can be hit in a wallet rpc server.
Package wallet provides a client that encapsulates RPC methods that can be hit in a wallet rpc server.

Jump to

Keyboard shortcuts

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