bchwallet: github.com/gcash/bchwallet/rpc/legacyrpc Index | Files

package legacyrpc

import "github.com/gcash/bchwallet/rpc/legacyrpc"


Package Files

config.go errors.go log.go methods.go rpcserverhelp.go server.go


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

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

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

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

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

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

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

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

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

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

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

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

func UseLogger Uses

func UseLogger(logger bchlog.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).

type DeserializationError Uses

type DeserializationError struct {
    // contains filtered or unexported fields

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

type InvalidParameterError Uses

type InvalidParameterError struct {
    // contains filtered or unexported fields

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

type Options Uses

type Options struct {
    Username string
    Password string

    MaxPOSTClients      int64
    MaxWebsocketClients int64

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

type ParseError Uses

type ParseError struct {
    // contains filtered or unexported fields

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

type Server Uses

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 Uses

func NewServer(opts *Options, walletLoader *wallet.Loader, listeners []net.Listener) *Server

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

func (*Server) RegisterWallet Uses

func (s *Server) RegisterWallet(w *wallet.Wallet)

RegisterWallet associates the legacy RPC server with the wallet. This function must be called before any wallet RPCs can be called by clients.

func (*Server) RequestProcessShutdown Uses

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

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

func (*Server) SetChainServer Uses

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

SetChainServer sets the chain server client component needed to run a fully functional bitcoin 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 Uses

func (s *Server) Stop()

Stop gracefully shuts down the rpc server by stopping and disconnecting all clients, disconnecting the chain server connection, and closing the wallet's account files. This blocks until shutdown completes.

Package legacyrpc imports 30 packages (graph) and is imported by 2 packages. Updated 2019-12-06. Refresh now. Tools for package owners.