Documentation ¶
Index ¶
- Constants
- Variables
- func InitialiseService(store Store, overwrite bool) error
- func IsInitialised(store Store) (bool, error)
- func NewAuth(log *zap.Logger, cfgStore RSAStore, tokenExpiry time.Duration) (*auth, error)
- func ParseSubmitTransactionRequest(r *http.Request) (*walletpb.SubmitTransactionRequest, commands.Errors)
- type Auth
- type Claims
- type CreateWalletRequest
- type CreateWalletResponse
- type ErrorResponse
- type ErrorsResponse
- type GenKeyPairRequest
- type ImportWalletRequest
- type KeyResponse
- type KeysResponse
- type LoginWalletRequest
- type NetworkResponse
- type NodeForward
- type RSAKeys
- type RSAStore
- type Service
- func (s *Service) CreateWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) GenerateKeyPair(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) GetNetwork(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *Service) GetPublicKey(t string, w http.ResponseWriter, _ *http.Request, ps httprouter.Params)
- func (s *Service) Health(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) ImportWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) ListPublicKeys(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *Service) Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) Revoke(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *Service) SignAny(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) SignTx(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *Service) SignTxCommit(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *Service) SignTxSync(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) TaintKey(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *Service) UpdateMeta(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *Service) VerifyAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) Version(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- type SignAnyRequest
- type SignAnyResponse
- type Store
- type SuccessResponse
- type TaintKeyRequest
- type TokenResponse
- type UpdateMetaRequest
- type VerifyAnyRequest
- type VerifyAnyResponse
- type VersionResponse
- type WalletHandler
Constants ¶
const (
LengthForSessionHashSeed = 10
)
Variables ¶
var ( ErrInvalidToken = errors.New("invalid token") ErrInvalidClaims = errors.New("invalid claims") ErrInvalidOrMissingToken = newErrorResponse("invalid or missing token") ErrCouldNotReadRequest = errors.New("couldn't read request") ErrCouldNotGetBlockHeight = errors.New("couldn't get last block height") ErrShouldBeBase64Encoded = errors.New("should be base64 encoded") ErrRSAKeysAlreadyExists = errors.New("RSA keys already exist") )
var ErrSessionNotFound = errors.New("session not found")
Functions ¶
func InitialiseService ¶
func IsInitialised ¶ added in v0.11.0
Types ¶
type Auth ¶
type Auth interface { NewSession(name string) (string, error) VerifyToken(token string) (string, error) Revoke(token string) (string, error) }
Auth ...
type CreateWalletRequest ¶
type CreateWalletRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` }
CreateWalletRequest describes the request for CreateWallet.
func ParseCreateWalletRequest ¶
func ParseCreateWalletRequest(r *http.Request) (*CreateWalletRequest, commands.Errors)
type CreateWalletResponse ¶
type CreateWalletResponse struct { RecoveryPhrase string `json:"recoveryPhrase"` Token string `json:"token"` }
CreateWalletResponse returns the authentication token and the auto-generated recovery phrase of the created wallet.
type ErrorResponse ¶
type ErrorResponse struct { ErrorStr string `json:"error"` Details []string `json:"details,omitempty"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type ErrorsResponse ¶
type GenKeyPairRequest ¶
type GenKeyPairRequest struct { Passphrase string `json:"passphrase"` Meta []wallet.Meta `json:"meta"` }
GenKeyPairRequest describes the request for GenerateKeyPair.
func ParseGenKeyPairRequest ¶
func ParseGenKeyPairRequest(r *http.Request) (*GenKeyPairRequest, commands.Errors)
type ImportWalletRequest ¶
type ImportWalletRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` RecoveryPhrase string `json:"recoveryPhrase"` Version uint32 `json:"version"` }
ImportWalletRequest describes the request for ImportWallet.
func ParseImportWalletRequest ¶
func ParseImportWalletRequest(r *http.Request) (*ImportWalletRequest, commands.Errors)
type KeyResponse ¶
KeyResponse describes the response to a request that returns a single key.
type KeysResponse ¶
KeysResponse describes the response to a request that returns a list of keys.
type LoginWalletRequest ¶
type LoginWalletRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` }
LoginWalletRequest describes the request for CreateWallet, LoginWallet.
func ParseLoginWalletRequest ¶
func ParseLoginWalletRequest(r *http.Request) (*LoginWalletRequest, commands.Errors)
type NetworkResponse ¶
NetworkResponse describes the response to a request that returns app hosts info.
type NodeForward ¶
type NodeForward interface { SendTx(context.Context, *commandspb.Transaction, api.SubmitTransactionRequest_Type) (string, error) HealthCheck(context.Context) error LastBlockHeight(context.Context) (uint64, error) }
NodeForward ...
type RSAKeys ¶
func GenerateRSAKeys ¶
type Service ¶
type Service struct { *httprouter.Router // contains filtered or unexported fields }
func NewService ¶
func NewService(log *zap.Logger, net *network.Network, h WalletHandler, a Auth, n NodeForward) (*Service, error)
func (*Service) CreateWallet ¶
func (s *Service) CreateWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) GenerateKeyPair ¶
func (s *Service) GenerateKeyPair(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) GetNetwork ¶
func (s *Service) GetNetwork(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Service) GetPublicKey ¶
func (s *Service) GetPublicKey(t string, w http.ResponseWriter, _ *http.Request, ps httprouter.Params)
func (*Service) Health ¶
func (s *Service) Health(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) ImportWallet ¶
func (s *Service) ImportWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) ListPublicKeys ¶
func (s *Service) ListPublicKeys(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Service) Login ¶
func (s *Service) Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) Revoke ¶
func (s *Service) Revoke(t string, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Service) SignAny ¶
func (s *Service) SignAny(t string, w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) SignTx ¶
func (s *Service) SignTx(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Service) SignTxCommit ¶
func (s *Service) SignTxCommit(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Service) SignTxSync ¶
func (s *Service) SignTxSync(token string, w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Service) TaintKey ¶
func (s *Service) TaintKey(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Service) UpdateMeta ¶
func (s *Service) UpdateMeta(t string, w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Service) VerifyAny ¶
func (s *Service) VerifyAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) Version ¶
func (s *Service) Version(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
type SignAnyRequest ¶
type SignAnyRequest struct { // InputData is the payload to generate a signature from. I should be // base 64 encoded. InputData string `json:"inputData"` // PubKey is used to retrieve the private key to sign the InputDate. PubKey string `json:"pubKey"` // contains filtered or unexported fields }
SignAnyRequest describes the request for SignAny.
func ParseSignAnyRequest ¶
func ParseSignAnyRequest(r *http.Request) (*SignAnyRequest, commands.Errors)
type SignAnyResponse ¶
type SignAnyResponse struct { HexSignature string `json:"hexSignature"` Base64Signature string `json:"base64Signature"` }
SignAnyResponse describes the response for SignAny.
type SuccessResponse ¶
type SuccessResponse struct {
Success bool `json:"success"`
}
SuccessResponse describes the response to a request that returns a simple true/false answer.
type TaintKeyRequest ¶
type TaintKeyRequest struct {
Passphrase string `json:"passphrase"`
}
TaintKeyRequest describes the request for TaintKey.
func ParseTaintKeyRequest ¶
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
TokenResponse describes the response to a request that returns a token.
type UpdateMetaRequest ¶
type UpdateMetaRequest struct { Passphrase string `json:"passphrase"` Meta []wallet.Meta `json:"meta"` }
UpdateMetaRequest describes the request for UpdateMeta.
func ParseUpdateMetaRequest ¶
type VerifyAnyRequest ¶
type VerifyAnyRequest struct { // InputData is the payload to be verified. It should be base64 encoded. InputData string `json:"inputData"` // Signature is the signature to check against the InputData. It should be // base64 encoded. Signature string `json:"signature"` // PubKey is the public key used along the signature to check the InputData. PubKey string `json:"pubKey"` // contains filtered or unexported fields }
VerifyAnyRequest describes the request for VerifyAny.
func ParseVerifyAnyRequest ¶
func ParseVerifyAnyRequest(r *http.Request) (*VerifyAnyRequest, commands.Errors)
type VerifyAnyResponse ¶ added in v0.9.2
type VerifyAnyResponse struct {
Valid bool `json:"success"`
}
VerifyAnyResponse describes the response for VerifyAny.
type VersionResponse ¶
type VersionResponse struct { Version string `json:"version"` VersionHash string `json:"versionHash"` }
VersionResponse describes the response to a request that returns app version info.
type WalletHandler ¶
type WalletHandler interface { CreateWallet(name, passphrase string) (string, error) ImportWallet(name, passphrase, recoveryPhrase string, version uint32) error LoginWallet(name, passphrase string) error LogoutWallet(name string) SecureGenerateKeyPair(name, passphrase string, meta []wallet.Meta) (string, error) GetPublicKey(name, pubKey string) (wallet.PublicKey, error) ListPublicKeys(name string) ([]wallet.PublicKey, error) SignTx(name string, req *walletpb.SubmitTransactionRequest, height uint64) (*commandspb.Transaction, error) SignAny(name string, inputData []byte, pubKey string) ([]byte, error) VerifyAny(inputData, sig []byte, pubKey string) (bool, error) TaintKey(name, pubKey, passphrase string) error UpdateMeta(name, pubKey, passphrase string, meta []wallet.Meta) error }
WalletHandler ...