Documentation
¶
Index ¶
- Constants
- Variables
- func ParseSubmitTransactionRequest(r *http.Request) (*walletpb.SubmitTransactionRequest, commands.Errors)
- type API
- func (s *API) CheckTx(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) CreateWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) GenerateKeyPair(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) GetNetwork(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (s *API) GetNetworkChainID(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) GetPublicKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *API) Health(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) ImportWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) ListPublicKeys(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) Revoke(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) SignAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) SignTx(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *API) SignTxCommit(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *API) SignTxSync(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (s *API) TaintKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *API) UpdateMeta(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *API) VerifyAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *API) Version(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- type Auth
- type AutomaticConsentPolicy
- type Claims
- type ConsentConfirmation
- type ConsentRequest
- type CreateWalletRequest
- type CreateWalletResponse
- type ErrorResponse
- type ErrorsResponse
- type ExplicitConsentPolicy
- type GenKeyPairRequest
- type ImportWalletRequest
- type KeyKeyResponse
- type KeyResponse
- type KeysResponse
- type LoginWalletRequest
- type NetworkResponse
- type NodeForward
- type Policy
- type RSAKeys
- type RSAStore
- type SentTransaction
- type SignAnyRequest
- type SignAnyResponse
- type SpamHandler
- type SuccessResponse
- type TaintKeyRequest
- type TokenResponse
- type UpdateMetaRequest
- type VerifyAnyRequest
- type VerifyAnyResponse
- type VersionResponse
- type WalletHandler
Constants ¶
const ( TxnValidationFailure uint32 = 51 TxnDecodingFailure uint32 = 60 TxnInternalError uint32 = 70 TxnUnknownCommandError uint32 = 80 TxnSpamError uint32 = 89 )
const (
LengthForSessionHashSeed = 10
)
const TXIDLENGTH = 20
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") ErrCouldNotGetChainID = errors.New("couldn't get chain-id") ErrShouldBeBase64Encoded = errors.New("should be base64 encoded") ErrRejectedSignRequest = errors.New("user rejected sign request") ErrInterruptedConsentRequest = errors.New("process to request consent has been interrupted") )
var ErrSessionNotFound = errors.New("session not found")
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func NewAPI ¶
func NewAPI( log *zap.Logger, handler WalletHandler, auth Auth, nodeForward NodeForward, policy Policy, net *network.Network, spam SpamHandler, ) *API
func (*API) CheckTx ¶
func (s *API) CheckTx(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) CreateWallet ¶
func (s *API) CreateWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) GenerateKeyPair ¶
func (s *API) GenerateKeyPair(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) GetNetwork ¶
func (s *API) GetNetwork(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*API) GetNetworkChainID ¶
func (s *API) GetNetworkChainID(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) GetPublicKey ¶
func (s *API) GetPublicKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*API) Health ¶
func (s *API) Health(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) ImportWallet ¶
func (s *API) ImportWallet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) ListPublicKeys ¶
func (s *API) ListPublicKeys(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) Login ¶
func (s *API) Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) Revoke ¶
func (s *API) Revoke(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) SignAny ¶
func (s *API) SignAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) SignTx ¶
func (s *API) SignTx(w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*API) SignTxCommit ¶
func (s *API) SignTxCommit(w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*API) SignTxSync ¶
func (s *API) SignTxSync(w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*API) TaintKey ¶
func (s *API) TaintKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*API) UpdateMeta ¶
func (s *API) UpdateMeta(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*API) VerifyAny ¶
func (s *API) VerifyAny(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*API) Version ¶
func (s *API) Version(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
type Auth ¶
type AutomaticConsentPolicy ¶
type AutomaticConsentPolicy struct{}
func (*AutomaticConsentPolicy) Ask ¶
func (p *AutomaticConsentPolicy) Ask(_ *v1.SubmitTransactionRequest, _ string, _ time.Time) (bool, error)
func (*AutomaticConsentPolicy) Report ¶
func (p *AutomaticConsentPolicy) Report(_ SentTransaction)
type ConsentConfirmation ¶
type ConsentRequest ¶
type ConsentRequest struct {
TxID string
Tx *v1.SubmitTransactionRequest
ReceivedAt time.Time
Confirmation chan ConsentConfirmation
}
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 ExplicitConsentPolicy ¶
type ExplicitConsentPolicy struct {
// contains filtered or unexported fields
}
func (*ExplicitConsentPolicy) Ask ¶
func (p *ExplicitConsentPolicy) Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error)
func (*ExplicitConsentPolicy) Report ¶
func (p *ExplicitConsentPolicy) Report(tx SentTransaction)
type GenKeyPairRequest ¶
type GenKeyPairRequest struct {
Passphrase string `json:"passphrase"`
Meta []wallet.Metadata `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 KeyKeyResponse ¶
type KeyResponse ¶
type KeyResponse struct {
Key KeyKeyResponse `json:"key"`
}
KeyResponse describes the response to a request that returns a single key.
type KeysResponse ¶
type KeysResponse struct {
Keys []KeyKeyResponse `json:"keys"`
}
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, int) (*api.SubmitTransactionResponse, error)
CheckTx(context.Context, *commandspb.Transaction, int) (*api.CheckTransactionResponse, error)
HealthCheck(context.Context) error
LastBlockHeightAndHash(context.Context) (*api.LastBlockHeightResponse, int, error)
SpamStatistics(context.Context, string) (*api.GetSpamStatisticsResponse, int, error)
Stop()
}
type Policy ¶
type Policy interface {
Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error)
Report(tx SentTransaction)
}
func NewAutomaticConsentPolicy ¶
func NewAutomaticConsentPolicy() Policy
func NewExplicitConsentPolicy ¶
func NewExplicitConsentPolicy(ctx context.Context, consentRequests chan ConsentRequest, sentTransactions chan SentTransaction) Policy
type RSAKeys ¶
func GenerateRSAKeys ¶
type SentTransaction ¶
type SentTransaction struct {
TxHash string
TxID string
Tx *commandspb.Transaction
Error error
SentAt time.Time
}
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 SpamHandler ¶ added in v0.68.0
type SpamHandler interface {
GenerateProofOfWork(pubKey string, stats *nodetypes.SpamStatistics) (*commandspb.ProofOfWork, error)
CheckSubmission(req *walletpb.SubmitTransactionRequest, stats *nodetypes.SpamStatistics) error
}
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.Metadata `json:"meta"`
}
UpdateMetaRequest describes the request for UpdateMetadata.
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 ¶
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
SecureGenerateKeyPair(name, passphrase string, meta []wallet.Metadata) (string, error)
GetPublicKey(name, pubKey string) (wallet.PublicKey, error)
ListPublicKeys(name string) ([]wallet.PublicKey, error)
SignTx(name string, req *walletpb.SubmitTransactionRequest, height uint64, chainID string) (*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.Metadata) error
}