controller

package
v0.0.0-...-9cc8e37 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidAccountError = ErrorResponse{
	Error: "Invalid account",
}
View Source
var InvalidHashError = ErrorResponse{
	Error: "Invalid hash",
}
View Source
var InvalidKeyError = ErrorResponse{
	Error: "Invalid key",
}
View Source
var InvalidSeedError = ErrorResponse{
	Error: "Invalid seed",
}
View Source
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"}
View Source
var UnableToParseJsonError = ErrorResponse{
	Error: "Unable to parse json",
}
View Source
var WalletLockedError = ErrorResponse{
	Error: "wallet locked",
}
View Source
var WalletNoPasswordError = ErrorResponse{
	Error: "password not set",
}
View Source
var WalletNotFoundError = ErrorResponse{
	Error: "wallet not found",
}
View Source
var WalletNotLockedError = ErrorResponse{
	Error: "wallet not locked",
}
View Source
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

Jump to

Keyboard shortcuts

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