rpcclient

package
v4.11.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package rpcclient contains the API to the physical device.

Package rpcclient manages the connection with the bitboxbase, establishing a websocket listener and sending events when receiving packets. It also acts as a rpc client for any external package wanting to communicate with the base

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetEnvResponse

type GetEnvResponse struct {
	Network        string
	ElectrsRPCPort string
}

GetEnvResponse holds the information from the rpc call reply to get some environment data from the base

type RPCClient

type RPCClient struct {
	observable.Implementation
	// contains filtered or unexported fields
}

RPCClient implements observable blockchainInfo.

func NewRPCClient

func NewRPCClient(address string, bitboxBaseConfigDir string, onUnregister func(string), bitboxBaseID string) *RPCClient

NewRPCClient returns a new bitboxbase rpcClient.

func (*RPCClient) Connect

func (rpcClient *RPCClient) Connect(bitboxBaseID string) error

Connect starts the websocket go routine, first checking if the middleware is reachable, then establishing a websocket connection, then authenticating and encrypting all further traffic with noise.

func (*RPCClient) GetEnv

func (rpcClient *RPCClient) GetEnv() (GetEnvResponse, error)

GetEnv makes a synchronous rpc call to the base and returns the network type and electrs rpc port

func (*RPCClient) Ping

func (rpcClient *RPCClient) Ping() (bool, error)

Ping sends a get request to the bitbox base's middleware root handler and returns true if successful

func (*RPCClient) SampleInfo

func (rpcClient *RPCClient) SampleInfo() (SampleInfoResponse, error)

SampleInfo make a synchronous rpc call to the base, emits an event containing the SampleInfo struct to the frontend and returns the SampleInfo struct

func (*RPCClient) Stop

func (rpcClient *RPCClient) Stop()

Stop shuts down the websocket connection with the base

type SampleInfoResponse

type SampleInfoResponse struct {
	Blocks         int64   `json:"blocks"`
	Difficulty     float64 `json:"difficulty"`
	LightningAlias string  `json:"lightningAlias"`
}

SampleInfoResponse holds some sample information from the BitBox Base

Jump to

Keyboard shortcuts

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