Documentation ¶
Index ¶
- Variables
- func ErrBadRequest(w http.ResponseWriter, r *http.Request, errorText string)
- func ErrInternalServerError(w http.ResponseWriter, r *http.Request, errorText string)
- func ErrInvalidAccount(w http.ResponseWriter, r *http.Request)
- func ErrInvalidHash(w http.ResponseWriter, r *http.Request)
- func ErrInvalidKey(w http.ResponseWriter, r *http.Request)
- func ErrInvalidSeed(w http.ResponseWriter, r *http.Request)
- func ErrNoWalletPassword(w http.ResponseWriter, r *http.Request)
- func ErrUnableToParseJson(w http.ResponseWriter, r *http.Request)
- func ErrWalletLocked(w http.ResponseWriter, r *http.Request)
- func ErrWalletNotFound(w http.ResponseWriter, r *http.Request)
- func ErrWalletNotLocked(w http.ResponseWriter, r *http.Request)
- func ErrWorkFailed(w http.ResponseWriter, r *http.Request)
- type ErrorResponse
- type HttpController
- func (hc *HttpController) DecodeAccountCreateRequest(request *map[string]interface{}, w http.ResponseWriter, r *http.Request) (*requests.AccountCreateRequest, *int)
- func (hc *HttpController) DecodeBaseRequest(request *map[string]interface{}, w http.ResponseWriter, r *http.Request) *requests.BaseRequest
- func (hc *HttpController) DecodeBaseRequestWithCount(request *map[string]interface{}, w http.ResponseWriter, r *http.Request) (*requests.BaseRequestWithCount, int)
- func (hc *HttpController) Gateway(w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleAccountCreate(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleAccountList(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleAccountRepresentativeSetRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleAccountsCreate(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandlePasswordChange(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandlePasswordEnter(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleReceiveAllRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleReceiveRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleSendRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletAdd(request *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletBalances(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletChangeSeedRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletContains(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletCreate(request *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletDestroy(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletFrontiers(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletInfo(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletLock(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletLocked(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletPending(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletRepresentativeRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWalletRepresentativeSetRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) HandleWorkGenerate(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
- func (hc *HttpController) WalletExists(walletId string, w http.ResponseWriter, r *http.Request) *ent.Wallet
Constants ¶
This section is empty.
Variables ¶
var InvalidAccountError = ErrorResponse{
Error: "Invalid account",
}
var InvalidHashError = ErrorResponse{
Error: "Invalid hash",
}
var InvalidKeyError = ErrorResponse{
Error: "Invalid key",
}
var InvalidSeedError = ErrorResponse{
Error: "Invalid seed",
}
var UNSUPPORTED_WALLET_ACTIONS = []string{"account_move", "account_remove", "receive_minimum", "receive_minimum_set", "search_pending", "search_pending_all", "wallet_add_watch", "wallet_export", "wallet_history", "wallet_ledger", "wallet_republish", "wallet_work_get", "work_get", "work_set"}
var UnableToParseJsonError = ErrorResponse{
Error: "Unable to parse json",
}
var WalletLockedError = ErrorResponse{
Error: "wallet locked",
}
var WalletNoPasswordError = ErrorResponse{
Error: "password not set",
}
var WalletNotFoundError = ErrorResponse{
Error: "wallet not found",
}
var WalletNotLockedError = ErrorResponse{
Error: "wallet not locked",
}
var WorkFailedError = ErrorResponse{
Error: "Failed to generate work",
}
Functions ¶
func ErrBadRequest ¶
func ErrBadRequest(w http.ResponseWriter, r *http.Request, errorText string)
func ErrInternalServerError ¶
func ErrInternalServerError(w http.ResponseWriter, r *http.Request, errorText string)
func ErrInvalidAccount ¶
func ErrInvalidAccount(w http.ResponseWriter, r *http.Request)
func ErrInvalidHash ¶
func ErrInvalidHash(w http.ResponseWriter, r *http.Request)
func ErrInvalidKey ¶
func ErrInvalidKey(w http.ResponseWriter, r *http.Request)
func ErrInvalidSeed ¶
func ErrInvalidSeed(w http.ResponseWriter, r *http.Request)
func ErrNoWalletPassword ¶
func ErrNoWalletPassword(w http.ResponseWriter, r *http.Request)
func ErrUnableToParseJson ¶
func ErrUnableToParseJson(w http.ResponseWriter, r *http.Request)
func ErrWalletLocked ¶
func ErrWalletLocked(w http.ResponseWriter, r *http.Request)
func ErrWalletNotFound ¶
func ErrWalletNotFound(w http.ResponseWriter, r *http.Request)
func ErrWalletNotLocked ¶
func ErrWalletNotLocked(w http.ResponseWriter, r *http.Request)
func ErrWorkFailed ¶
func ErrWorkFailed(w http.ResponseWriter, r *http.Request)
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type HttpController ¶
type HttpController struct { Wallet *wallet.NanoWallet RpcClient *rpc.RPCClient PowClient *pow.PippinPow }
func (*HttpController) DecodeAccountCreateRequest ¶
func (hc *HttpController) DecodeAccountCreateRequest(request *map[string]interface{}, w http.ResponseWriter, r *http.Request) (*requests.AccountCreateRequest, *int)
! TODO - can we reduce duplication with generics or something ?
func (*HttpController) DecodeBaseRequest ¶
func (hc *HttpController) DecodeBaseRequest(request *map[string]interface{}, w http.ResponseWriter, r *http.Request) *requests.BaseRequest
Common map decoding for most requests
func (*HttpController) DecodeBaseRequestWithCount ¶
func (hc *HttpController) DecodeBaseRequestWithCount(request *map[string]interface{}, w http.ResponseWriter, r *http.Request) (*requests.BaseRequestWithCount, int)
Common map decoding for requests with count added
func (*HttpController) Gateway ¶
func (hc *HttpController) Gateway(w http.ResponseWriter, r *http.Request)
This is called the "Gateway" because it's the entry point for all requests This API is intended to replace the nano node wallet RPCs https://docs.nano.org/commands/rpc-protocol/#wallet-rpcs It will: 1) Determine if the request is a supported wallet RPC, if so process it 2) If it's a wallet RPC we don't support, return error 3) Other requests with a correct signature go straight to the node The error messages and behavior are also intended to replace what the nano node returns The node isn't exactly great at returning errors, and the error messages are not very helpful But as we want to be a drop-in replacement we mimic the behavior
func (*HttpController) HandleAccountCreate ¶
func (hc *HttpController) HandleAccountCreate(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Create a new account in sequence for given wallet ! TODO - we don't support setting a specific index like the node does, not sure the best way around that with how we handle our sequencing
func (*HttpController) HandleAccountList ¶
func (hc *HttpController) HandleAccountList(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle accounts_list
func (*HttpController) HandleAccountRepresentativeSetRequest ¶
func (hc *HttpController) HandleAccountRepresentativeSetRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle rep change
func (*HttpController) HandleAccountsCreate ¶
func (hc *HttpController) HandleAccountsCreate(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle bulk account create based on count param
func (*HttpController) HandlePasswordChange ¶
func (hc *HttpController) HandlePasswordChange(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandlePasswordEnter ¶
func (hc *HttpController) HandlePasswordEnter(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Password enter is to unlock the wallet
func (*HttpController) HandleReceiveAllRequest ¶
func (hc *HttpController) HandleReceiveAllRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle receive all blocks in entire wallet
func (*HttpController) HandleReceiveRequest ¶
func (hc *HttpController) HandleReceiveRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle receive individual block
func (*HttpController) HandleSendRequest ¶
func (hc *HttpController) HandleSendRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle send block
func (*HttpController) HandleWalletAdd ¶
func (hc *HttpController) HandleWalletAdd(request *map[string]interface{}, w http.ResponseWriter, r *http.Request)
For adding adhoc keys to the wallet
func (*HttpController) HandleWalletBalances ¶
func (hc *HttpController) HandleWalletBalances(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletChangeSeedRequest ¶
func (hc *HttpController) HandleWalletChangeSeedRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletContains ¶
func (hc *HttpController) HandleWalletContains(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletCreate ¶
func (hc *HttpController) HandleWalletCreate(request *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletDestroy ¶
func (hc *HttpController) HandleWalletDestroy(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletFrontiers ¶
func (hc *HttpController) HandleWalletFrontiers(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletInfo ¶
func (hc *HttpController) HandleWalletInfo(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletLock ¶
func (hc *HttpController) HandleWalletLock(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletLocked ¶
func (hc *HttpController) HandleWalletLocked(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
Handle wallet locked, returns whether or not wallet is locked
func (*HttpController) HandleWalletPending ¶
func (hc *HttpController) HandleWalletPending(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletRepresentativeRequest ¶
func (hc *HttpController) HandleWalletRepresentativeRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWalletRepresentativeSetRequest ¶
func (hc *HttpController) HandleWalletRepresentativeSetRequest(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) HandleWorkGenerate ¶
func (hc *HttpController) HandleWorkGenerate(rawRequest *map[string]interface{}, w http.ResponseWriter, r *http.Request)
func (*HttpController) WalletExists ¶
func (hc *HttpController) WalletExists(walletId string, w http.ResponseWriter, r *http.Request) *ent.Wallet
Get wallet if it exists, set response