Documentation ¶
Overview ¶
AUTOGENERATED by internal/rpchelp/genrpcserverhelp.go; do not edit.
Index ¶
- Constants
- Variables
- func AddMultiSigAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func Confirms(txHeight, curHeight int32) int32
- func CreateMultiSig(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func CreateNewAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func DecodeAddress(s string, params *netparams.Params) (util.Address, error)
- func DecodeHexStr(hexStr string) ([]byte, error)
- func DumpPrivKey(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetAccountAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetAddressesByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetBalance(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetBestBlock(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetBestBlockHash(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetBlockCount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetInfo(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
- func GetNewAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetRawChangeAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetReceivedByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetReceivedByAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetTransaction(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func GetUnconfirmedBalance(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func HTTPBasicAuth(username, password string) []byte
- func Help(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
- func HelpDescsEnUS() map[string]string
- func HelpNoChainRPC(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func HelpWithChainRPC(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
- func IDPointer(id interface{}) (p *interface{})
- func ImportPrivKey(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func IsNilOrEmpty(s *string) bool
- func JSONAuthFail(w http.ResponseWriter)
- func JSONError(err error) *btcjson.RPCError
- func KeypoolRefill(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListAccounts(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListAllTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListLockUnspent(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListReceivedByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListReceivedByAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListSinceBlock(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
- func ListTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func ListUnspent(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func LockUnspent(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func MakeMultiSigScript(w *wallet.Wallet, keys []string, nRequired int) ([]byte, error)
- func MakeOutputs(pairs map[string]util.Amount, chainParams *netparams.Params) ([]*wire.TxOut, error)
- func MakeResponse(id, result interface{}, err error) btcjson.Response
- func RenameAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func SendFrom(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
- func SendMany(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func SendPairs(w *wallet.Wallet, amounts map[string]util.Amount, account uint32, ...) (string, error)
- func SendToAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func SetTxFee(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func SignMessage(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func SignRawTransaction(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
- func Throttled(threshold int64, h http.Handler) http.Handler
- func ThrottledFn(threshold int64, f http.HandlerFunc) http.Handler
- func Unimplemented(interface{}, *wallet.Wallet) (interface{}, error)
- func Unsupported(interface{}, *wallet.Wallet) (interface{}, error)
- func ValidateAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func VerifyMessage(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func WalletIsLocked(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func WalletLock(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func WalletPassphrase(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- func WalletPassphraseChange(icmd interface{}, w *wallet.Wallet) (interface{}, error)
- type DeserializationError
- type InvalidParameterError
- type LazyHandler
- type Options
- type ParseError
- type RequestHandler
- type RequestHandlerChainRequired
- type Server
- func (s *Server) CheckAuthHeader(r *http.Request) error
- func (s *Server) HandlerClosure(request *btcjson.Request) LazyHandler
- func (s *Server) InvalidAuth(req *btcjson.Request) bool
- func (s *Server) POSTClientRPC(w http.ResponseWriter, r *http.Request)
- func (s *Server) RegisterWallet(w *wallet.Wallet)
- func (s *Server) RequestProcessShutdown()
- func (s *Server) RequestProcessShutdownChan() <-chan struct{}
- func (s *Server) Serve(lis net.Listener)
- func (s *Server) SetChainServer(chainClient chain.Interface)
- func (s *Server) Stop()
- func (s *Server) WebsocketClientRPC(wsc *WebsocketClient)
- func (s *Server) WebsocketClientRead(wsc *WebsocketClient)
- func (s *Server) WebsocketClientRespond(wsc *WebsocketClient)
- func (s *Server) WebsocketClientSend(wsc *WebsocketClient)
- type WebsocketClient
Constants ¶
const MaxRequestSize = 1024 * 1024 * 4
MaxRequestSize specifies the maximum number of bytes in the request body that may be read from a client. This is currently limited to 4MB.
Variables ¶
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.
var HelpDescs map[string]string
These generators create the following global variables in this package:
var localeHelpDescs map[string]func() map[string]string var requestUsages string
localeHelpDescs maps from locale strings (e.g. "en_US") to a function that builds a map of help texts for each RPC server method. This prevents help text maps for every locale map from being rooted and created during init. Instead, the appropiate function is looked up when help text is first needed using the current locale and saved to the global below for futher reuse.
requestUsages contains single line usages for every supported request, separated by newlines. It is set during init. These usages are used for all locales.
var HelpDescsMutex sync.Mutex // Help may execute concurrently, so synchronize access.
var LocaleHelpDescs = map[string]func() map[string]string{ "en_US": HelpDescsEnUS, }
var RPCHandlers = map[string]struct { Handler RequestHandler HandlerWithChain RequestHandlerChainRequired // Function variables cannot be compared against anything but nil, so // use a boolean to record whether help generation is necessary. This // is used by the tests to ensure that help can be generated for every // implemented method. // // A single map and this bool is here is used rather than several maps // for the unimplemented handlers so every method has exactly one // handler function. NoHelp bool }{ "addmultisigaddress": {Handler: AddMultiSigAddress}, "createmultisig": {Handler: CreateMultiSig}, "dumpprivkey": {Handler: DumpPrivKey}, "getaccount": {Handler: GetAccount}, "getaccountaddress": {Handler: GetAccountAddress}, "getaddressesbyaccount": {Handler: GetAddressesByAccount}, "getbalance": {Handler: GetBalance}, "getbestblockhash": {Handler: GetBestBlockHash}, "getblockcount": {Handler: GetBlockCount}, "getinfo": {HandlerWithChain: GetInfo}, "getnewaddress": {Handler: GetNewAddress}, "getrawchangeaddress": {Handler: GetRawChangeAddress}, "getreceivedbyaccount": {Handler: GetReceivedByAccount}, "getreceivedbyaddress": {Handler: GetReceivedByAddress}, "gettransaction": {Handler: GetTransaction}, "help": {Handler: HelpNoChainRPC, HandlerWithChain: HelpWithChainRPC}, "importprivkey": {Handler: ImportPrivKey}, "keypoolrefill": {Handler: KeypoolRefill}, "listaccounts": {Handler: ListAccounts}, "listlockunspent": {Handler: ListLockUnspent}, "listreceivedbyaccount": {Handler: ListReceivedByAccount}, "listreceivedbyaddress": {Handler: ListReceivedByAddress}, "listsinceblock": {HandlerWithChain: ListSinceBlock}, "listtransactions": {Handler: ListTransactions}, "listunspent": {Handler: ListUnspent}, "lockunspent": {Handler: LockUnspent}, "sendfrom": {HandlerWithChain: SendFrom}, "sendmany": {Handler: SendMany}, "sendtoaddress": {Handler: SendToAddress}, "settxfee": {Handler: SetTxFee}, "signmessage": {Handler: SignMessage}, "signrawtransaction": {HandlerWithChain: SignRawTransaction}, "validateaddress": {Handler: ValidateAddress}, "verifymessage": {Handler: VerifyMessage}, "walletlock": {Handler: WalletLock}, "walletpassphrase": {Handler: WalletPassphrase}, "walletpassphrasechange": {Handler: WalletPassphraseChange}, "backupwallet": {Handler: Unimplemented, NoHelp: true}, "dumpwallet": {Handler: Unimplemented, NoHelp: true}, "getwalletinfo": {Handler: Unimplemented, NoHelp: true}, "importwallet": {Handler: Unimplemented, NoHelp: true}, "listaddressgroupings": {Handler: Unimplemented, NoHelp: true}, "encryptwallet": {Handler: Unsupported, NoHelp: true}, "move": {Handler: Unsupported, NoHelp: true}, "setaccount": {Handler: Unsupported, NoHelp: true}, "createnewaccount": {Handler: CreateNewAccount}, "getbestblock": {Handler: GetBestBlock}, "getunconfirmedbalance": {Handler: GetUnconfirmedBalance}, "listaddresstransactions": {Handler: ListAddressTransactions}, "listalltransactions": {Handler: ListAllTransactions}, "renameaccount": {Handler: RenameAccount}, "walletislocked": {Handler: WalletIsLocked}, }
var RequestUsages = "" /* 1969-byte string literal not displayed */
Functions ¶
func AddMultiSigAddress ¶
AddMultiSigAddress handles an addmultisigaddress request by adding a multisig address to the given wallet.
func Confirms ¶
Confirms returns the number of confirmations for a transaction in a block at height txHeight (or -1 for an unconfirmed tx) given the chain height curHeight.
func CreateMultiSig ¶
CreateMultiSig handles an createmultisig request by returning a multisig address for the given inputs.
func CreateNewAccount ¶
CreateNewAccount handles a createnewaccount request by creating and returning a new account. If the last account has no transaction history as per BIP 0044 a new account cannot be created so an error will be returned.
func DecodeHexStr ¶
DecodeHexStr decodes the hex encoding of a string, possibly prepending a leading '0' character if there is an odd number of bytes in the hex string. This is to prevent an error for an invalid hex string when using an odd number of bytes when calling hex.Decode.
func DumpPrivKey ¶
DumpPrivKey handles a dumpprivkey request with the private key for a single address, or an appropiate error if the wallet is locked.
func GetAccount ¶
GetAccount handles a getaccount request by returning the account name associated with a single address.
func GetAccountAddress ¶
GetAccountAddress handles a getaccountaddress by returning the most recently-created chained address that has not yet been used (does not yet appear in the blockchain, or any tx that has arrived in the pod mempool). If the most recently-requested address has been used, a new address (the next chained address in the keypool) is used. This can fail if the keypool runs out (and will return json.ErrRPCWalletKeypoolRanOut if that happens).
func GetAddressesByAccount ¶
GetAddressesByAccount handles a getaddressesbyaccount request by returning all addresses for an account, or an error if the requested account does not exist.
func GetBalance ¶
GetBalance handles a getbalance request by returning the balance for an account (wallet), or an error if the requested account does not exist.
func GetBestBlock ¶
GetBestBlock handles a getbestblock request by returning a JSON object with the height and hash of the most recently processed block.
func GetBestBlockHash ¶
GetBestBlockHash handles a getbestblockhash request by returning the hash of the most recently processed block.
func GetBlockCount ¶
GetBlockCount handles a getblockcount request by returning the chain height of the most recently processed block.
func GetInfo ¶
GetInfo handles a getinfo request by returning the a structure containing information about the current state of btcwallet. exist.
func GetNewAddress ¶
GetNewAddress handles a getnewaddress request by returning a new address for an account. If the account does not exist an appropiate error is returned. TODO: Follow BIP 0044 and warn if number of unused addresses exceeds the gap limit.
func GetRawChangeAddress ¶
GetRawChangeAddress handles a getrawchangeaddress request by creating and returning a new change address for an account.
Note: bitcoind allows specifying the account as an optional parameter, but ignores the parameter.
func GetReceivedByAccount ¶
GetReceivedByAccount handles a getreceivedbyaccount request by returning the total amount received by addresses of an account.
func GetReceivedByAddress ¶
GetReceivedByAddress handles a getreceivedbyaddress request by returning the total amount received by a single address.
func GetTransaction ¶
GetTransaction handles a gettransaction request by returning details about a single transaction saved by wallet.
func GetUnconfirmedBalance ¶
GetUnconfirmedBalance handles a getunconfirmedbalance extension request by returning the current unconfirmed balance of an account.
func HTTPBasicAuth ¶
HTTPBasicAuth returns the UTF-8 bytes of the HTTP Basic authentication string:
"Basic " + base64(username + ":" + password)
func Help ¶
Help handles the Help request by returning one line usage of all available methods, or full Help for a specific method. The chainClient is optional, and this is simply a helper function for the HelpNoChainRPC and HelpWithChainRPC handlers.
func HelpDescsEnUS ¶
func HelpNoChainRPC ¶
HelpNoChainRPC handles the help request when the RPC server has not been associated with a consensus RPC client. No help messages are included for passthrough requests.
func HelpWithChainRPC ¶
func HelpWithChainRPC(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
HelpWithChainRPC handles the help request when the RPC server has been associated with a consensus RPC client. The additional RPC client is used to include help messages for methods implemented by the consensus server via RPC passthrough.
func IDPointer ¶
func IDPointer(id interface{}) (p *interface{})
IDPointer returns a pointer to the passed ID, or nil if the interface is nil. Interface pointers are usually a red flag of doing something incorrectly, but this is only implemented here to work around an oddity with json, which uses empty interface pointers for response IDs.
func ImportPrivKey ¶
ImportPrivKey handles an importprivkey request by parsing a WIF-encoded private key and adding it to an account.
func IsNilOrEmpty ¶
func JSONAuthFail ¶
func JSONAuthFail(w http.ResponseWriter)
JSONAuthFail sends a message back to the client if the http auth is rejected.
func KeypoolRefill ¶
KeypoolRefill handles the keypoolrefill command. Since we handle the keypool automatically this does nothing since refilling is never manually required.
func ListAccounts ¶
ListAccounts handles a listaccounts request by returning a map of account names to their balances.
func ListAddressTransactions ¶
ListAddressTransactions handles a listaddresstransactions request by returning an array of maps with details of spent and received wallet transactions. The form of the reply is identical to listtransactions, but the array elements are limited to transaction details which are about the addresess included in the request.
func ListAllTransactions ¶
ListAllTransactions handles a listalltransactions request by returning a map with details of sent and recevied wallet transactions. This is similar to ListTransactions, except it takes only a single optional argument for the account name and replies with all transactions.
func ListLockUnspent ¶
ListLockUnspent handles a listlockunspent request by returning an slice of all locked outpoints.
func ListReceivedByAccount ¶
ListReceivedByAccount handles a listreceivedbyaccount request by returning a slice of objects, each one containing:
"account": the receiving account; "amount": total amount received by the account; "confirmations": number of confirmations of the most recent transaction.
It takes two parameters:
"minconf": minimum number of confirmations to consider a transaction - default: one; "includeempty": whether or not to include addresses that have no transactions - default: false.
func ListReceivedByAddress ¶
ListReceivedByAddress handles a listreceivedbyaddress request by returning a slice of objects, each one containing:
"account": the account of the receiving address; "address": the receiving address; "amount": total amount received by the address; "confirmations": number of confirmations of the most recent transaction.
It takes two parameters:
"minconf": minimum number of confirmations to consider a transaction - default: one; "includeempty": whether or not to include addresses that have no transactions - default: false.
func ListSinceBlock ¶
func ListSinceBlock(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
ListSinceBlock handles a listsinceblock request by returning an array of maps with details of sent and received wallet transactions since the given block.
func ListTransactions ¶
ListTransactions handles a listtransactions request by returning an array of maps with details of sent and recevied wallet transactions.
func ListUnspent ¶
ListUnspent handles the listunspent command.
func LockUnspent ¶
LockUnspent handles the lockunspent command.
func MakeMultiSigScript ¶
MakeMultiSigScript is a helper function to combine common logic for AddMultiSig and CreateMultiSig.
func MakeOutputs ¶
func MakeOutputs(pairs map[string]util.Amount, chainParams *netparams.Params) ([]*wire.TxOut, error)
MakeOutputs creates a slice of transaction outputs from a pair of address strings to amounts. This is used to create the outputs to include in newly created transactions from a JSON object describing the output destinations and amounts.
func MakeResponse ¶
MakeResponse makes the JSON-RPC response struct for the result and error returned by a requestHandler. The returned response is not ready for marshaling and sending off to a client, but must be
func RenameAccount ¶
RenameAccount handles a renameaccount request by renaming an account. If the account does not exist an appropiate error will be returned.
func SendFrom ¶
func SendFrom(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
SendFrom handles a sendfrom RPC request by creating a new transaction spending unspent transaction outputs for a wallet to another payment address. Leftover inputs not sent to the payment address or a fee for the miner are sent back to a new address in the wallet. Upon success, the TxID for the created transaction is returned.
func SendMany ¶
SendMany handles a sendmany RPC request by creating a new transaction spending unspent transaction outputs for a wallet to any number of payment addresses. Leftover inputs not sent to the payment address or a fee for the miner are sent back to a new address in the wallet. Upon success, the TxID for the created transaction is returned.
func SendPairs ¶
func SendPairs(w *wallet.Wallet, amounts map[string]util.Amount, account uint32, minconf int32, feeSatPerKb util.Amount) (string, error)
SendPairs creates and sends payment transactions. It returns the transaction hash in string format upon success All errors are returned in json.RPCError format
func SendToAddress ¶
SendToAddress handles a sendtoaddress RPC request by creating a new transaction spending unspent transaction outputs for a wallet to another payment address. Leftover inputs not sent to the payment address or a fee for the miner are sent back to a new address in the wallet. Upon success, the TxID for the created transaction is returned.
func SignMessage ¶
SignMessage signs the given message with the private key for the given address
func SignRawTransaction ¶
func SignRawTransaction(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient) (interface{}, error)
SignRawTransaction handles the signrawtransaction command.
func Throttled ¶
Throttled wraps an http.Handler with throttling of concurrent active clients by responding with an HTTP 429 when the threshold is crossed.
func ThrottledFn ¶
func ThrottledFn(threshold int64, f http.HandlerFunc) http.Handler
ThrottledFn wraps an http.HandlerFunc with throttling of concurrent active clients by responding with an HTTP 429 when the threshold is crossed.
func Unimplemented ¶
Unimplemented handles an Unimplemented RPC request with the appropiate error.
func Unsupported ¶
Unsupported handles a standard bitcoind RPC request which is Unsupported by btcwallet due to design differences.
func ValidateAddress ¶
ValidateAddress handles the validateaddress command.
func VerifyMessage ¶
VerifyMessage handles the verifymessage command by verifying the provided compact signature for the given address and message.
func WalletIsLocked ¶
WalletIsLocked handles the walletislocked extension request by returning the current lock state (false for unlocked, true for locked) of an account.
func WalletLock ¶
WalletLock handles a walletlock request by locking the all account wallets, returning an error if any wallet is not encrypted (for example, a watching-only wallet).
func WalletPassphrase ¶
WalletPassphrase responds to the walletpassphrase request by unlocking the wallet. The decryption key is saved in the wallet until timeout seconds expires, after which the wallet is locked.
func WalletPassphraseChange ¶
WalletPassphraseChange responds to the walletpassphrasechange request by unlocking all accounts with the provided old passphrase, and re-encrypting each private key with an AES key derived from the new passphrase.
If the old passphrase is correct and the passphrase is changed, all wallets will be immediately locked.
Types ¶
type DeserializationError ¶
type DeserializationError struct {
// contains filtered or unexported fields
}
DeserializationError describes a failed deserializaion due to bad user input. It corresponds to json.ErrRPCDeserialization.
type InvalidParameterError ¶
type InvalidParameterError struct {
// contains filtered or unexported fields
}
InvalidParameterError describes an invalid parameter passed by the user. It corresponds to json.ErrRPCInvalidParameter.
type LazyHandler ¶
LazyHandler is a closure over a requestHandler or passthrough request with the RPC server's wallet and chain server variables as part of the closure context.
func LazyApplyHandler ¶
func LazyApplyHandler(request *btcjson.Request, w *wallet.Wallet, chainClient chain.Interface) LazyHandler
LazyApplyHandler looks up the best request handler func for the method, returning a closure that will execute it with the (required) wallet and (optional) consensus RPC server. If no handlers are found and the chainClient is not nil, the returned handler performs RPC passthrough.
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 json.ErrRPCParse.
type RequestHandler ¶
RequestHandler is a handler function to handle an unmarshaled and parsed request into a marshalable response. If the error is a *json.RPCError or any of the above special error classes, the server will respond with the JSON-RPC appropiate error code. All other errors use the wallet catch-all error code, json.ErrRPCWallet.
type RequestHandlerChainRequired ¶
type RequestHandlerChainRequired func(interface{}, *wallet.Wallet, *chain.RPCClient) (interface{}, error)
requestHandlerChain is a requestHandler that also takes a parameter for
type Server ¶
type Server struct { HTTPServer http.Server Wallet *wallet.Wallet WalletLoader *wallet.Loader ChainClient chain.Interface // handlerLookup func(string) (requestHandler, bool) HandlerMutex sync.Mutex Listeners []net.Listener AuthSHA [sha256.Size]byte Upgrader websocket.Upgrader MaxPostClients int64 // Max concurrent HTTP POST clients. MaxWebsocketClients int64 // Max concurrent websocket clients. WG sync.WaitGroup Quit chan struct{} QuitMutex sync.Mutex RequestShutdownChan chan struct{} }
Server holds the items the RPC server may need to access (auth, config, shutdown, etc.)
func NewServer ¶
NewServer creates a new server for serving legacy RPC client connections, both HTTP POST and websocket.
func (*Server) CheckAuthHeader ¶
CheckAuthHeader checks the HTTP Basic authentication supplied by a client in the HTTP request r. It errors with ErrNoAuth if the request does not contain the Authorization header, or another non-nil error if the authentication was provided but incorrect.
This check is time-constant.
func (*Server) HandlerClosure ¶
func (s *Server) HandlerClosure(request *btcjson.Request) LazyHandler
HandlerClosure creates a closure function for handling requests of the given method. This may be a request that is handled directly by btcwallet, or a chain server request that is handled by passing the request down to pod.
NOTE: These handlers do not handle special cases, such as the authenticate method. Each of these must be checked beforehand (the method is already known) and handled accordingly.
func (*Server) InvalidAuth ¶
InvalidAuth checks whether a websocket request is a valid (parsable) authenticate request and checks the supplied username and passphrase against the server auth.
func (*Server) POSTClientRPC ¶
func (s *Server) POSTClientRPC(w http.ResponseWriter, r *http.Request)
POSTClientRPC processes and replies to a JSON-RPC client request.
func (*Server) RegisterWallet ¶
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 ¶
func (s *Server) RequestProcessShutdown()
func (*Server) RequestProcessShutdownChan ¶
func (s *Server) RequestProcessShutdownChan() <-chan struct{}
RequestProcessShutdownChan returns a channel that is sent to when an authorized client requests remote shutdown.
func (*Server) Serve ¶
Serve serves HTTP POST and websocket RPC for the legacy JSON-RPC RPC server. This function does not block on lis.Accept.
func (*Server) SetChainServer ¶
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 ¶
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.
func (*Server) WebsocketClientRPC ¶
func (s *Server) WebsocketClientRPC(wsc *WebsocketClient)
WebsocketClientRPC starts the goroutines to serve JSON-RPC requests over a websocket connection for a single client.
func (*Server) WebsocketClientRead ¶
func (s *Server) WebsocketClientRead(wsc *WebsocketClient)
func (*Server) WebsocketClientRespond ¶
func (s *Server) WebsocketClientRespond(wsc *WebsocketClient)
func (*Server) WebsocketClientSend ¶
func (s *Server) WebsocketClientSend(wsc *WebsocketClient)
type WebsocketClient ¶
type WebsocketClient struct {
// contains filtered or unexported fields
}
func NewWebsocketClient ¶
func NewWebsocketClient(c *websocket.Conn, authenticated bool, remoteAddr string) *WebsocketClient
func (*WebsocketClient) Send ¶
func (c *WebsocketClient) Send(b []byte) error