legacyrpc

package
v0.0.0-...-516309f Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: ISC Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNeedPositiveAmount = InvalidParameterError{
		errors.New("amount must be positive"),
	}

	ErrNeedBelowMaxAmount = InvalidParameterError{
		errors.New("amount must be below max amount"),
	}

	ErrNeedPositiveSpendLimit = InvalidParameterError{
		errors.New("spend limit must be positive"),
	}

	ErrNeedPositiveMinconf = InvalidParameterError{
		errors.New("minconf must be positive"),
	}

	ErrAddressNotInWallet = exccjson.RPCError{
		Code:    exccjson.ErrRPCWallet,
		Message: "address not found in wallet",
	}

	ErrAccountNameNotFound = exccjson.RPCError{
		Code:    exccjson.ErrRPCWalletInvalidAccountName,
		Message: "account name not found",
	}

	ErrUnloadedWallet = exccjson.RPCError{
		Code:    exccjson.ErrRPCWallet,
		Message: "Request requires a wallet but wallet has not loaded yet",
	}

	ErrClientNotConnected = exccjson.RPCError{
		Code:    exccjson.ErrRPCClientNotConnected,
		Message: "RPC client has not connected yet",
	}

	ErrWalletUnlockNeeded = exccjson.RPCError{
		Code:    exccjson.ErrRPCWalletUnlockNeeded,
		Message: "Enter the wallet passphrase with walletpassphrase first",
	}

	ErrNotImportedAccount = exccjson.RPCError{
		Code:    exccjson.ErrRPCWallet,
		Message: "imported addresses must belong to the imported account",
	}

	ErrNoTransactionInfo = exccjson.RPCError{
		Code:    exccjson.ErrRPCNoTxInfo,
		Message: "No information for transaction",
	}

	ErrReservedAccountName = exccjson.RPCError{
		Code:    exccjson.ErrRPCInvalidParameter,
		Message: "Account name is reserved by RPC server",
	}

	ErrMainNetSafety = exccjson.RPCError{
		Code:    exccjson.ErrRPCWallet,
		Message: "RPC function disabled on MainNet wallets for security purposes",
	}
)

Errors variables that are defined once here to avoid duplication below.

View Source
var ErrNoAuth = errors.New("no auth")

ErrNoAuth represents an error where authentication could not succeed due to a missing Authorization HTTP header.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger sets the package-wide logger. Any calls to this function must be made before a server is created and used (it is not concurrent safe).

Types

type DeserializationError

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

DeserializationError describes a failed deserializaion due to bad user input. It corresponds to exccjson.ErrRPCDeserialization.

type InvalidParameterError

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

InvalidParameterError describes an invalid parameter passed by the user. It corresponds to exccjson.ErrRPCInvalidParameter.

type Options

type Options struct {
	Username string
	Password string

	MaxPOSTClients      int64
	MaxWebsocketClients int64
}

Options contains the required options for running the legacy RPC server.

type ParseError

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

ParseError describes a failed parse due to bad user input. It corresponds to exccjson.ErrRPCParse.

type Server

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

Server holds the items the RPC server may need to access (auth, config, shutdown, etc.)

func NewServer

func NewServer(opts *Options, activeNet *chaincfg.Params, walletLoader *loader.Loader, ticketBuyerConfig *ticketbuyer.Config, listeners []net.Listener) *Server

NewServer creates a new server for serving legacy RPC client connections, both HTTP POST and websocket.

func (*Server) RequestProcessShutdown

func (s *Server) RequestProcessShutdown() <-chan struct{}

RequestProcessShutdown returns a channel that is sent to when an authorized client requests remote shutdown.

func (*Server) SetChainServer

func (s *Server) SetChainServer(chainClient *chain.RPCClient)

SetChainServer sets the chain server client component needed to run a fully functional ExchangeCoin wallet RPC server. This can be called to enable RPC passthrough even before a loaded wallet is set, but the wallet's RPC client is preferred.

func (*Server) Stop

func (s *Server) Stop()

Stop gracefully shuts down the rpc server by stopping and disconnecting all clients. This blocks until shutdown completes.

Jump to

Keyboard shortcuts

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