Documentation ¶
Overview ¶
Package api exposes all the wallet capabilities to manage connections, wallets, keys, and transactions.
It is built with th JSON-RPC v2 standard. More info: See https://www.jsonrpc.org/specification for more information.
Terminology ¶
User:
The user is the actor behind the API that has the responsibility to review and validate the requests. It can be a human or a bot.
Wallet front-end:
The wallet front-end is the interface through which the user interact with the API. It can be a command-line interface, a graphical user-interface, or a script.
Third-party application:
The application that connects to the API (through HTTP or directly to JSON-RPC) to access wallets information, send transaction, etc.
Third-party application workflow ¶
All applications consuming this API should start with the following workflow:
connect_wallet: it allows the third-party application to initiate the connection with the API.
get_permissions: the application requires permissions from the user to consume the API. As a result, it should check if it has enough.
request_permissions: if the application doesn't have enough permissions to work, it has to request some.
Index ¶
- Constants
- Variables
- func AdminAPI(log *zap.Logger, walletStore WalletStore, netStore NetworkStore, ...) (*jsonrpc.API, error)
- func SessionAPI(log *zap.Logger, walletStore WalletStore, pipeline Pipeline, ...) (*jsonrpc.API, error)
- func TraceIDFromContext(ctx context.Context) string
- type AdminAnnotateKey
- type AdminAnnotateKeyParams
- type AdminAnnotateKeyResult
- type AdminCreateWallet
- type AdminCreateWalletParams
- type AdminCreateWalletResult
- type AdminCreatedWallet
- type AdminDescribeKey
- type AdminDescribeKeyParams
- type AdminDescribeKeyResult
- type AdminDescribeNetwork
- type AdminDescribeNetworkParams
- type AdminDescribeNetworkResult
- type AdminDescribePermissions
- type AdminDescribePermissionsParams
- type AdminDescribePermissionsResult
- type AdminDescribeWallet
- type AdminDescribeWalletParams
- type AdminDescribeWalletResult
- type AdminFirstPublicKey
- type AdminGenerateKey
- type AdminGenerateKeyParams
- type AdminGenerateKeyResult
- type AdminImportNetwork
- type AdminImportNetworkParams
- type AdminImportNetworkResult
- type AdminImportWallet
- type AdminImportWalletParams
- type AdminImportWalletResult
- type AdminImportedWallet
- type AdminIsolateKey
- type AdminIsolateKeyParams
- type AdminIsolateKeyResult
- type AdminLastBlockData
- type AdminListKeys
- type AdminListKeysParams
- type AdminListKeysResult
- type AdminListNetworks
- type AdminListNetworksResult
- type AdminListPermissions
- type AdminListPermissionsParams
- type AdminListPermissionsResult
- type AdminListWallets
- type AdminListWalletsResult
- type AdminNamedPublicKey
- type AdminPurgePermissions
- type AdminPurgePermissionsParams
- type AdminRemoveNetwork
- type AdminRemoveNetworkParams
- type AdminRemoveWallet
- type AdminRemoveWalletParams
- type AdminRevokePermissions
- type AdminRevokePermissionsParams
- type AdminRotateKey
- type AdminRotateKeyParams
- type AdminRotateKeyResult
- type AdminSendTransaction
- type AdminSendTransactionParams
- type AdminSendTransactionResult
- type AdminSignMessage
- type AdminSignMessageParams
- type AdminSignMessageResult
- type AdminSignTransaction
- type AdminSignTransactionParams
- type AdminSignTransactionResult
- type AdminTaintKey
- type AdminTaintKeyParams
- type AdminUntaintKey
- type AdminUntaintKeyParams
- type AdminUpdateNetwork
- type AdminUpdateNetworkParams
- type AdminUpdatePermissions
- type AdminUpdatePermissionsParams
- type AdminUpdatePermissionsResult
- type AdminVerifyMessage
- type AdminVerifyMessageParams
- type AdminVerifyMessageResult
- type ConnectWallet
- type ConnectWalletParams
- type ConnectWalletResult
- type ConnectedWallet
- type DisconnectWallet
- type DisconnectWalletParams
- type ErrorType
- type GetChainID
- type GetChainIDResult
- type GetPermissions
- type GetPermissionsParams
- type GetPermissionsResult
- type LogType
- type NetworkStore
- type NodeSelectorBuilder
- type ParsedAdminSendTransactionParams
- type ParsedAdminSignTransactionParams
- type ParsedSendTransactionParams
- type ParsedSignTransactionParams
- type Pipeline
- type Reader
- type Readers
- type RequestPermissions
- type RequestPermissionsParams
- type RequestPermissionsResult
- type SelectedWallet
- type SendTransaction
- type SendTransactionParams
- type SendTransactionResult
- type SessionListKeys
- type SessionListKeysParams
- type SessionListKeysResult
- type SessionNamedPublicKey
- type Sessions
- type SignTransaction
- type SignTransactionParams
- type SignTransactionResult
- type WalletStore
Constants ¶
const ( // ErrorCodeNodeRequestFailed refers to the inability of the program to // talk to the network nodes. ErrorCodeNodeRequestFailed jsonrpc.ErrorCode = 1000 // ErrorCodeRequestNotPermitted refers a request made by a third-party application // that is not permitted to do. ErrorCodeRequestNotPermitted jsonrpc.ErrorCode = 2000 // ErrorCodeConnectionHasBeenClosed refers to an interruption of the service triggered // by the user. ErrorCodeConnectionHasBeenClosed jsonrpc.ErrorCode = 3000 // ErrorCodeRequestHasBeenRejected refers to an explicit rejection of a request by the // user. ErrorCodeRequestHasBeenRejected jsonrpc.ErrorCode = 3001 )
Variables ¶
var ( ErrBlockHashIsRequired = errors.New("the block hash is required") ErrBlockHeightIsRequired = errors.New("the block-height is required") ErrCannotRotateKeysOnIsolatedWallet = errors.New("cannot rotate keys on an isolated wallet") ErrChainIDIsRequired = errors.New("the chain ID is required") ErrConnectionTokenIsRequired = errors.New("the connection token is required") ErrCouldNotConnectToWallet = errors.New("could not connect to the wallet") ErrCouldNotGetChainIDFromNode = errors.New("could not get the chain ID from the node") ErrCouldNotGetLastBlockInformation = errors.New("could not get information about the last block on the network") ErrCouldNotRequestPermissions = errors.New("could not request permissions") ErrCouldNotSendTransaction = errors.New("could not send transaction") ErrCouldNotSignTransaction = errors.New("could not sign transaction") ErrCurrentPublicKeyDoesNotExist = errors.New("the current public key does not exist") ErrCurrentPublicKeyIsRequired = errors.New("the next public key is required") ErrEnactmentBlockHeightIsRequired = errors.New("the enactment block height is required") ErrEnactmentBlockHeightMustBeGreaterThanSubmissionOne = errors.New("the enactment block height must be greater than the submission one") ErrEncodedMessageIsNotValidBase64String = errors.New("the encoded message is not a valid base-64 string") ErrEncodedSignatureIsNotValidBase64String = errors.New("the encoded signature is not a valid base-64 string") ErrEncodedTransactionIsNotValidBase64String = errors.New("the encoded transaction is not a valid base-64 string") ErrEncodedTransactionIsRequired = errors.New("the encoded transaction is required") ErrHostnameIsRequired = errors.New("the hostname is required") ErrLastBlockDataOrNetworkIsRequired = errors.New("a network or the last block data is required") ErrMessageIsRequired = errors.New("the the message is required") ErrMultipleNetworkSources = errors.New("network sources are mutually exclusive") ErrNetworkAlreadyExists = errors.New("a network with the same name already exists") ErrNetworkConfigurationDoesNotHaveGRPCNodes = errors.New("the network does not have gRPC hosts configured") ErrNetworkDoesNotExist = errors.New("the network does not exist") ErrNetworkIsRequired = errors.New("the network is required") ErrNetworkNameIsRequired = errors.New("the network name is required") ErrNetworkOrNodeAddressIsRequired = errors.New("a network or a node address is required") ErrNetworkSourceIsRequired = errors.New("a network source is required") ErrNextAndCurrentPublicKeysCannotBeTheSame = errors.New("the next and current public keys cannot be the same") ErrNextPublicKeyDoesNotExist = errors.New("the next public key does not exist") ErrNextPublicKeyIsRequired = errors.New("the next public key is required") ErrNextPublicKeyIsTainted = errors.New("the next public key is tainted") ErrNoHealthyNodeAvailable = errors.New("no healthy node available") ErrParamsDoNotMatch = errors.New("the params do not match expected ones") ErrParamsRequired = errors.New("the params are required") ErrPassphraseIsRequired = errors.New("the passphrase is required") ErrProofOfWorkDifficultyRequired = errors.New("the proof-of-work difficulty is required") ErrProofOfWorkHashFunctionRequired = errors.New("the proof-of-work hash function is required") ErrPublicKeyDoesNotExist = errors.New("the public key does not exist") ErrPublicKeyIsNotAllowedToBeUsed = errors.New("the public key is not allowed to be used") ErrPublicKeyIsRequired = errors.New("the public key is required") ErrReadAccessOnPublicKeysRequired = errors.New(`a "read" access on public keys is required`) ErrRecoveryPhraseIsRequired = errors.New("the recovery phrase is required") ErrRequestInterrupted = errors.New("the request has been interrupted") ErrRequestedPermissionsAreRequired = errors.New("the requested permissions are required") ErrSendingModeCannotBeTypeUnspecified = errors.New(`the sending mode can't be "TYPE_UNSPECIFIED"`) ErrSendingModeIsRequired = errors.New("the sending mode is required") ErrSignatureIsRequired = errors.New("the the signature is required") ErrSpecifyingNetworkAndLastBlockDataIsNotSupported = errors.New("specifying a network and the last block data is not supported") ErrSpecifyingNetworkAndNodeAddressIsNotSupported = errors.New("specifying a network and a node address is not supported") ErrSubmissionBlockHeightIsRequired = errors.New("the submission block height is required") ErrInvalidLogLevelValue = errors.New("invalid log level value") ErrInvalidTokenExpiryValue = errors.New("invalid token expiry value") ErrTransactionFailed = errors.New("the transaction failed") ErrTransactionIsMalformed = errors.New("the transaction is malformed") ErrUserCloseTheConnection = errors.New("the user closed the connection") ErrUserRejectedTheRequest = errors.New("the user rejected the request") ErrWalletAlreadyExists = errors.New("a wallet with the same name already exists") ErrWalletDoesNotExist = errors.New("the wallet does not exist") ErrWalletIsRequired = errors.New("the wallet is required") ErrWalletVersionIsRequired = errors.New("the wallet version is required") )
var ErrInvalidNetworkSource = errors.New("invalid network source")
var ErrNoWalletConnected = errors.New("no wallet connected")
Functions ¶
func AdminAPI ¶ added in v0.55.0
func AdminAPI(log *zap.Logger, walletStore WalletStore, netStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder) (*jsonrpc.API, error)
AdminAPI builds the JSON-RPC API of the wallet with all the methods available. This API exposes highly-sensitive methods, and, as a result, it should be only exposed to highly-trustable applications.
func SessionAPI ¶ added in v0.55.0
func SessionAPI(log *zap.Logger, walletStore WalletStore, pipeline Pipeline, nodeSelector node.Selector) (*jsonrpc.API, error)
SessionAPI builds the wallet JSON-RPC API with specific methods that are intended to be publicly exposed to third-party applications in a non-trustable environment. Because of the nature of the environment from where these methods are called, no administration methods are exposed. We don't want malicious third-party applications to leverage administration capabilities that could expose to the user and compromise his wallets.
func TraceIDFromContext ¶
Types ¶
type AdminAnnotateKey ¶ added in v0.55.0
type AdminAnnotateKey struct {
// contains filtered or unexported fields
}
func NewAdminAnnotateKey ¶ added in v0.55.0
func NewAdminAnnotateKey( walletStore WalletStore, ) *AdminAnnotateKey
func (*AdminAnnotateKey) Handle ¶ added in v0.55.0
func (h *AdminAnnotateKey) Handle(ctx context.Context, rawParams jsonrpc.Params) (jsonrpc.Result, *jsonrpc.ErrorDetails)
Handle attaches metadata to the specified public key. It doesn't update in place. It overwrites. All existing metadata have to be specified to not lose them.
type AdminAnnotateKeyParams ¶ added in v0.55.0
type AdminAnnotateKeyResult ¶ added in v0.55.0
type AdminCreateWallet ¶ added in v0.55.0
type AdminCreateWallet struct {
// contains filtered or unexported fields
}
func NewAdminCreateWallet ¶ added in v0.55.0
func NewAdminCreateWallet( walletStore WalletStore, ) *AdminCreateWallet
type AdminCreateWalletParams ¶ added in v0.55.0
type AdminCreateWalletResult ¶ added in v0.55.0
type AdminCreateWalletResult struct { Wallet AdminCreatedWallet `json:"wallet"` Key AdminFirstPublicKey `json:"key"` }
type AdminCreatedWallet ¶ added in v0.55.0
type AdminDescribeKey ¶ added in v0.55.0
type AdminDescribeKey struct {
// contains filtered or unexported fields
}
func NewAdminDescribeKey ¶ added in v0.55.0
func NewAdminDescribeKey( walletStore WalletStore, ) *AdminDescribeKey
type AdminDescribeKeyParams ¶ added in v0.55.0
type AdminDescribeKeyResult ¶ added in v0.55.0
type AdminDescribeNetwork ¶ added in v0.55.0
type AdminDescribeNetwork struct {
// contains filtered or unexported fields
}
func NewAdminDescribeNetwork ¶ added in v0.55.0
func NewAdminDescribeNetwork( networkStore NetworkStore, ) *AdminDescribeNetwork
type AdminDescribeNetworkParams ¶ added in v0.55.0
type AdminDescribeNetworkParams struct {
Network string `json:"network"`
}
type AdminDescribeNetworkResult ¶ added in v0.55.0
type AdminDescribeNetworkResult struct { Name string `json:"name"` LogLevel vgencoding.LogLevel `json:"logLevel"` TokenExpiry vgencoding.Duration `json:"tokenExpiry"` Port int `json:"port"` Host string `json:"host"` API struct { GRPCConfig struct { Hosts []string `json:"hosts"` Retries uint64 `json:"retries"` } `json:"grpcConfig"` RESTConfig struct { Hosts []string `json:"hosts"` } `json:"restConfig"` GraphQLConfig struct { Hosts []string `json:"hosts"` } `json:"graphQLConfig"` } `json:"api"` }
type AdminDescribePermissions ¶ added in v0.55.0
type AdminDescribePermissions struct {
// contains filtered or unexported fields
}
func NewAdminDescribePermissions ¶ added in v0.55.0
func NewAdminDescribePermissions( walletStore WalletStore, ) *AdminDescribePermissions
type AdminDescribePermissionsParams ¶ added in v0.55.0
type AdminDescribePermissionsResult ¶ added in v0.55.0
type AdminDescribePermissionsResult struct {
Permissions wallet.Permissions `json:"permissions"`
}
type AdminDescribeWallet ¶ added in v0.55.0
type AdminDescribeWallet struct {
// contains filtered or unexported fields
}
func NewAdminDescribeWallet ¶ added in v0.55.0
func NewAdminDescribeWallet( walletStore WalletStore, ) *AdminDescribeWallet
type AdminDescribeWalletParams ¶ added in v0.55.0
type AdminDescribeWalletResult ¶ added in v0.55.0
type AdminFirstPublicKey ¶ added in v0.55.0
type AdminGenerateKey ¶ added in v0.55.0
type AdminGenerateKey struct {
// contains filtered or unexported fields
}
func NewAdminGenerateKey ¶ added in v0.55.0
func NewAdminGenerateKey( walletStore WalletStore, ) *AdminGenerateKey
type AdminGenerateKeyParams ¶ added in v0.55.0
type AdminGenerateKeyResult ¶ added in v0.55.0
type AdminImportNetwork ¶ added in v0.55.0
type AdminImportNetwork struct {
// contains filtered or unexported fields
}
func NewAdminImportNetwork ¶ added in v0.55.0
func NewAdminImportNetwork( networkStore NetworkStore, ) *AdminImportNetwork
type AdminImportNetworkParams ¶ added in v0.55.0
type AdminImportNetworkResult ¶ added in v0.55.0
type AdminImportWallet ¶ added in v0.55.0
type AdminImportWallet struct {
// contains filtered or unexported fields
}
func NewAdminImportWallet ¶ added in v0.55.0
func NewAdminImportWallet( walletStore WalletStore, ) *AdminImportWallet
type AdminImportWalletParams ¶ added in v0.55.0
type AdminImportWalletResult ¶ added in v0.55.0
type AdminImportWalletResult struct { Wallet AdminImportedWallet `json:"wallet"` Key AdminFirstPublicKey `json:"key"` }
type AdminImportedWallet ¶ added in v0.55.0
type AdminIsolateKey ¶ added in v0.55.0
type AdminIsolateKey struct {
// contains filtered or unexported fields
}
func NewAdminIsolateKey ¶ added in v0.55.0
func NewAdminIsolateKey( walletStore WalletStore, ) *AdminIsolateKey
type AdminIsolateKeyParams ¶ added in v0.55.0
type AdminIsolateKeyResult ¶ added in v0.55.0
type AdminLastBlockData ¶ added in v0.56.0
type AdminListKeys ¶ added in v0.55.0
type AdminListKeys struct {
// contains filtered or unexported fields
}
func NewAdminListKeys ¶ added in v0.55.0
func NewAdminListKeys( walletStore WalletStore, ) *AdminListKeys
type AdminListKeysParams ¶ added in v0.55.0
type AdminListKeysResult ¶ added in v0.55.0
type AdminListKeysResult struct {
PublicKeys []AdminNamedPublicKey `json:"keys"`
}
type AdminListNetworks ¶ added in v0.55.0
type AdminListNetworks struct {
// contains filtered or unexported fields
}
func NewAdminListNetworks ¶ added in v0.55.0
func NewAdminListNetworks( networkStore NetworkStore, ) *AdminListNetworks
type AdminListNetworksResult ¶ added in v0.55.0
type AdminListNetworksResult struct {
Networks []string `json:"networks"`
}
type AdminListPermissions ¶ added in v0.55.0
type AdminListPermissions struct {
// contains filtered or unexported fields
}
func NewAdminListPermissions ¶ added in v0.55.0
func NewAdminListPermissions( walletStore WalletStore, ) *AdminListPermissions
type AdminListPermissionsParams ¶ added in v0.55.0
type AdminListPermissionsResult ¶ added in v0.55.0
type AdminListPermissionsResult struct {
Permissions map[string]wallet.PermissionsSummary `json:"permissions"`
}
type AdminListWallets ¶ added in v0.55.0
type AdminListWallets struct {
// contains filtered or unexported fields
}
func NewAdminListWallets ¶ added in v0.55.0
func NewAdminListWallets( walletStore WalletStore, ) *AdminListWallets
type AdminListWalletsResult ¶ added in v0.55.0
type AdminListWalletsResult struct {
Wallets []string `json:"wallets"`
}
type AdminNamedPublicKey ¶ added in v0.55.0
type AdminPurgePermissions ¶ added in v0.55.0
type AdminPurgePermissions struct {
// contains filtered or unexported fields
}
func NewAdminPurgePermissions ¶ added in v0.55.0
func NewAdminPurgePermissions( walletStore WalletStore, ) *AdminPurgePermissions
type AdminPurgePermissionsParams ¶ added in v0.55.0
type AdminRemoveNetwork ¶ added in v0.55.0
type AdminRemoveNetwork struct {
// contains filtered or unexported fields
}
func NewAdminRemoveNetwork ¶ added in v0.55.0
func NewAdminRemoveNetwork( networkStore NetworkStore, ) *AdminRemoveNetwork
type AdminRemoveNetworkParams ¶ added in v0.55.0
type AdminRemoveNetworkParams struct {
Network string `json:"network"`
}
type AdminRemoveWallet ¶ added in v0.55.0
type AdminRemoveWallet struct {
// contains filtered or unexported fields
}
func NewAdminRemoveWallet ¶ added in v0.55.0
func NewAdminRemoveWallet( walletStore WalletStore, ) *AdminRemoveWallet
type AdminRemoveWalletParams ¶ added in v0.55.0
type AdminRemoveWalletParams struct {
Wallet string `json:"wallet"`
}
type AdminRevokePermissions ¶ added in v0.55.0
type AdminRevokePermissions struct {
// contains filtered or unexported fields
}
func NewAdminRevokePermissions ¶ added in v0.55.0
func NewAdminRevokePermissions( walletStore WalletStore, ) *AdminRevokePermissions
type AdminRevokePermissionsParams ¶ added in v0.55.0
type AdminRotateKey ¶ added in v0.55.0
type AdminRotateKey struct {
// contains filtered or unexported fields
}
func NewAdminRotateKey ¶ added in v0.55.0
func NewAdminRotateKey( walletStore WalletStore, ) *AdminRotateKey
type AdminRotateKeyParams ¶ added in v0.55.0
type AdminRotateKeyParams struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` FromPublicKey string `json:"fromPublicKey"` ToPublicKey string `json:"toPublicKey"` ChainID string `json:"chainID"` SubmissionBlockHeight uint64 `json:"submissionBlockHeight"` EnactmentBlockHeight uint64 `json:"enactmentBlockHeight"` }
type AdminRotateKeyResult ¶ added in v0.55.0
type AdminSendTransaction ¶ added in v0.56.0
type AdminSendTransaction struct {
// contains filtered or unexported fields
}
func NewAdminSendTransaction ¶ added in v0.56.0
func NewAdminSendTransaction(networkStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder) *AdminSendTransaction
type AdminSendTransactionParams ¶ added in v0.56.0
type AdminSendTransactionResult ¶ added in v0.56.0
type AdminSendTransactionResult struct { ReceivedAt time.Time `json:"receivedAt"` SentAt time.Time `json:"sentAt"` TxHash string `json:"transactionHash"` Tx *commandspb.Transaction `json:"transaction"` }
type AdminSignMessage ¶ added in v0.56.0
type AdminSignMessage struct {
// contains filtered or unexported fields
}
func NewAdminSignMessage ¶ added in v0.56.0
func NewAdminSignMessage(walletStore WalletStore) *AdminSignMessage
type AdminSignMessageParams ¶ added in v0.56.0
type AdminSignMessageResult ¶ added in v0.56.0
type AdminSignMessageResult struct {
Base64Signature string `json:"base64Signature"`
}
type AdminSignTransaction ¶ added in v0.56.0
type AdminSignTransaction struct {
// contains filtered or unexported fields
}
func NewAdminSignTransaction ¶ added in v0.56.0
func NewAdminSignTransaction(walletStore WalletStore, networkStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder) *AdminSignTransaction
type AdminSignTransactionParams ¶ added in v0.56.0
type AdminSignTransactionResult ¶ added in v0.56.0
type AdminSignTransactionResult struct { Tx *commandspb.Transaction `json:"transaction"` EncodedTransaction string }
type AdminTaintKey ¶ added in v0.55.0
type AdminTaintKey struct {
// contains filtered or unexported fields
}
func NewAdminTaintKey ¶ added in v0.55.0
func NewAdminTaintKey( walletStore WalletStore, ) *AdminTaintKey
type AdminTaintKeyParams ¶ added in v0.55.0
type AdminUntaintKey ¶ added in v0.55.0
type AdminUntaintKey struct {
// contains filtered or unexported fields
}
func NewAdminUntaintKey ¶ added in v0.55.0
func NewAdminUntaintKey( walletStore WalletStore, ) *AdminUntaintKey
type AdminUntaintKeyParams ¶ added in v0.55.0
type AdminUpdateNetwork ¶ added in v0.56.0
type AdminUpdateNetwork struct {
// contains filtered or unexported fields
}
func NewAdminUpdateNetwork ¶ added in v0.56.0
func NewAdminUpdateNetwork( networkStore NetworkStore, ) *AdminUpdateNetwork
type AdminUpdateNetworkParams ¶ added in v0.56.0
type AdminUpdateNetworkParams struct { Name string `json:"name"` Level string `json:"logLevel"` TokenExpiry string `json:"tokenExpiry"` Port int `json:"port"` Host string `json:"host"` API struct { GRPCConfig struct { Hosts []string `json:"hosts"` Retries uint64 `json:"retries"` } `json:"grpcConfig"` RESTConfig struct { Hosts []string `json:"hosts"` } `json:"restConfig"` GraphQLConfig struct { Hosts []string `json:"hosts"` } `json:"graphQLConfig"` } `json:"api"` }
type AdminUpdatePermissions ¶ added in v0.55.0
type AdminUpdatePermissions struct {
// contains filtered or unexported fields
}
func NewAdminUpdatePermissions ¶ added in v0.55.0
func NewAdminUpdatePermissions( walletStore WalletStore, ) *AdminUpdatePermissions
type AdminUpdatePermissionsParams ¶ added in v0.55.0
type AdminUpdatePermissionsParams struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` Hostname string `json:"hostname"` Permissions wallet.Permissions `json:"permissions"` }
type AdminUpdatePermissionsResult ¶ added in v0.55.0
type AdminUpdatePermissionsResult struct {
Permissions wallet.Permissions `json:"permissions"`
}
type AdminVerifyMessage ¶ added in v0.56.0
type AdminVerifyMessage struct{}
func NewAdminVerifyMessage ¶ added in v0.56.0
func NewAdminVerifyMessage() *AdminVerifyMessage
type AdminVerifyMessageParams ¶ added in v0.56.0
type AdminVerifyMessageResult ¶ added in v0.56.0
type AdminVerifyMessageResult struct {
IsValid bool `json:"valid"`
}
type ConnectWallet ¶
type ConnectWallet struct {
// contains filtered or unexported fields
}
func NewConnectWallet ¶
func NewConnectWallet( walletStore WalletStore, pipeline Pipeline, sessions *Sessions, ) *ConnectWallet
func (*ConnectWallet) Handle ¶
func (h *ConnectWallet) Handle(ctx context.Context, rawParams jsonrpc.Params) (jsonrpc.Result, *jsonrpc.ErrorDetails)
Handle initiates the wallet connection between the API and a third-party application.
It triggers a selection of the wallet the client wants to use for this connection. The wallet is then loaded in memory. All changes done to that wallet will start in-memory, and then, be saved in the wallet file. Any changes done to the wallet outside the JSON-RPC session (via the command-line for example) will be overridden. For the effects to be taken into account, the wallet has to be disconnected first, and then re-connected.
All sessions have to be initialized by using this handler. Otherwise, a call to any other handlers will be rejected.
type ConnectWalletParams ¶
type ConnectWalletParams struct {
Hostname string `json:"hostname"`
}
type ConnectWalletResult ¶
type ConnectWalletResult struct {
Token string `json:"token"`
}
type ConnectedWallet ¶
type ConnectedWallet struct { // Hostname is the hostname for which the connection is set. Hostname string // Wallet is the wallet selected by the client for this connection. Wallet wallet.Wallet // RestrictedKeys holds the keys that have been selected by the client // during the permissions request. RestrictedKeys map[string]wallet.KeyPair }
ConnectedWallet contains the resources and the information of the current connection, required by the wallet handlers to work, and based on the permissions the client has set.
func NewConnectedWallet ¶
func NewConnectedWallet(hostname string, w wallet.Wallet) (*ConnectedWallet, error)
func (*ConnectedWallet) CanUseKey ¶ added in v0.56.0
func (s *ConnectedWallet) CanUseKey(pubKey string) bool
CanUseKey determines is the permissions allow the specified key to be used, and ensure the key exist and is not tainted.
func (*ConnectedWallet) Permissions ¶
func (s *ConnectedWallet) Permissions() wallet.Permissions
func (*ConnectedWallet) ReloadWithWallet ¶
func (s *ConnectedWallet) ReloadWithWallet(updatedWallet wallet.Wallet) error
func (*ConnectedWallet) UpdatePermissions ¶
func (s *ConnectedWallet) UpdatePermissions(perms wallet.Permissions) error
type DisconnectWallet ¶
type DisconnectWallet struct {
// contains filtered or unexported fields
}
func NewDisconnectWallet ¶
func NewDisconnectWallet(sessions *Sessions) *DisconnectWallet
func (*DisconnectWallet) Handle ¶
func (h *DisconnectWallet) Handle(_ context.Context, rawParams jsonrpc.Params) (jsonrpc.Result, *jsonrpc.ErrorDetails)
Handle disconnect a wallet for a third-party application.
It does not fail. If there's no connected wallet for the given token, nothing happens.
The wallet resources are unloaded.
type DisconnectWalletParams ¶
type DisconnectWalletParams struct {
Token string `json:"hostname"`
}
type ErrorType ¶
type ErrorType string
ErrorType defines the type of error that is sent to the user, for fine grain error management and reporting.
var ( // InternalError defines an unexpected technical error upon which the user // can't act. // The wallet front-end should report it to the user and automatically // abort the processing of the ongoing request. // It can be raised if a file is not accessible or corrupt, for example. InternalError ErrorType = "Internal Error" // ServerError defines a programmatic error threw by the server, such as // a request cancellation. // It's a type of error that should be expected and handled. ServerError ErrorType = "Server Error" // NetworkError defines an error that comes from the network and its nodes. NetworkError ErrorType = "Network Error" // UserError defines an error that originated from the user and that // requires its intervention to correct it. // It can be raised if a passphrase is invalid, for example. UserError ErrorType = "User Error" )
type GetChainID ¶ added in v0.55.0
type GetChainID struct {
// contains filtered or unexported fields
}
func NewGetChainID ¶ added in v0.55.0
func NewGetChainID(nodeSelector walletnode.Selector) *GetChainID
type GetChainIDResult ¶ added in v0.55.0
type GetChainIDResult struct {
ChainID string `json:"chainID"`
}
type GetPermissions ¶
type GetPermissions struct {
// contains filtered or unexported fields
}
func NewGetPermissions ¶
func NewGetPermissions(sessions *Sessions) *GetPermissions
func (*GetPermissions) Handle ¶
func (h *GetPermissions) Handle(_ context.Context, rawParams jsonrpc.Params) (jsonrpc.Result, *jsonrpc.ErrorDetails)
Handle returns the permissions set on the given hostname.
If a third-party application does not have enough permissions, it has to request them using `request_permissions` handler.
Using this handler does not require permissions.
type GetPermissionsParams ¶
type GetPermissionsParams struct {
Token string `json:"token"`
}
type GetPermissionsResult ¶
type GetPermissionsResult struct {
Permissions wallet.PermissionsSummary `json:"permissions"`
}
type LogType ¶ added in v0.56.0
type LogType string
LogType defines the type of log that is sent to the user.
type NetworkStore ¶ added in v0.55.0
type NetworkStore interface { NetworkExists(string) (bool, error) GetNetwork(string) (*network.Network, error) SaveNetwork(*network.Network) error ListNetworks() ([]string, error) GetNetworkPath(string) string DeleteNetwork(string) error }
NetworkStore is the component used to retrieve and update the networks from the computer.
type NodeSelectorBuilder ¶ added in v0.56.0
type ParsedAdminSendTransactionParams ¶ added in v0.56.0
type ParsedAdminSignTransactionParams ¶ added in v0.56.0
type ParsedSendTransactionParams ¶
type ParsedSendTransactionParams struct { Token string PublicKey string SendingMode apipb.SubmitTransactionRequest_Type RawTransaction string }
type ParsedSignTransactionParams ¶ added in v0.55.0
type Pipeline ¶
type Pipeline interface { // NotifyError is used to report errors to the user. // This is a terminal message. Nothing should be expected on the request // after receiving this. NotifyError(ctx context.Context, traceID string, t ErrorType, err error) // Log is used to report information of any kind to the user. This is just // to log internal activity to provide feedback to the wallet front-end. // The log should be displayed without triggering any actions. // Receiving a success or an error log shouldn't be confused with the // NotifyError and NotifySuccessfulRequest that send terminal messages. Log(ctx context.Context, traceID string, t LogType, msg string) // RequestWalletConnectionReview is used to trigger a user review of // the wallet connection requested by the specified hostname. // It returns true if the user approved the wallet connection, false // otherwise. RequestWalletConnectionReview(ctx context.Context, traceID, hostname string) (bool, error) // NotifySuccessfulRequest is used to notify the user the request is // successful. // This is a terminal message. Nothing should be expected on the request // after receiving this. NotifySuccessfulRequest(ctx context.Context, traceID string) // RequestWalletSelection is used to trigger selection of the wallet the // user wants to use for the specified hostname. RequestWalletSelection(ctx context.Context, traceID, hostname string, availableWallets []string) (SelectedWallet, error) // RequestPassphrase is used to request the user to enter the passphrase of // the wallet. It's primarily used for request that requires saving changes // on it. RequestPassphrase(ctx context.Context, traceID, wallet string) (string, error) // RequestPermissionsReview is used to trigger a user review of the permissions // requested by the specified hostname. // It returns true if the user approved the requested permissions, false // otherwise. RequestPermissionsReview(ctx context.Context, traceID, hostname, wallet string, perms map[string]string) (bool, error) // RequestTransactionSendingReview is used to trigger a user review of the // transaction a third-party application wants to send. // It returns true if the user approved the sending of the transaction, // false otherwise. RequestTransactionSendingReview(ctx context.Context, traceID, hostname, wallet, pubKey, transaction string, receivedAt time.Time) (bool, error) // RequestTransactionSigningReview is used to trigger a user review of the // transaction a third-party application wants to sign. The wallet doesn't // send the transaction. // It returns true if the user approved the signing of the transaction, // false otherwise. RequestTransactionSigningReview(ctx context.Context, traceID, hostname, wallet, pubKey, transaction string, receivedAt time.Time) (bool, error) // NotifyTransactionStatus is used to report the transaction status once // sent. // This is a terminal message. Nothing should be expected on the request // after receiving this. NotifyTransactionStatus(ctx context.Context, traceID, txHash, tx string, err error, sentAt time.Time) }
Pipeline is the component connecting the wallet front-end and the JSON-RPC API. Convention:
- Notify* functions do not expect a response.
- Request* functions are expecting a user intervention.
type Readers ¶ added in v0.55.0
func NewReaders ¶ added in v0.55.0
func NewReaders() Readers
type RequestPermissions ¶
type RequestPermissions struct {
// contains filtered or unexported fields
}
func NewRequestPermissions ¶
func NewRequestPermissions( walletStore WalletStore, pipeline Pipeline, sessions *Sessions, ) *RequestPermissions
func (*RequestPermissions) Handle ¶
func (h *RequestPermissions) Handle(ctx context.Context, rawParams jsonrpc.Params) (jsonrpc.Result, *jsonrpc.ErrorDetails)
Handle allows a third-party application to request permissions to access certain capabilities of the wallet.
To update the permissions, the third-party application has to specify all the permissions it required, even those that are already active. This way the client get a full understanding of all the requested access, and is much more capable to evaluate abusive requests and applications. Any permission that is omitted is considered to be revoked.
The client will be asked to review the permissions the third-party application is requesting. It has the possibility to approve or reject the request.
Everytime the permissions are updated, the connected wallet resources are updated.
Using this handler does not require permissions.
type RequestPermissionsParams ¶
type RequestPermissionsParams struct { Token string `json:"token"` RequestedPermissions wallet.PermissionsSummary `json:"requestedPermissions"` }
type RequestPermissionsResult ¶
type RequestPermissionsResult struct {
Permissions wallet.PermissionsSummary `json:"permissions"`
}
type SelectedWallet ¶
SelectedWallet holds the result of the wallet selection from the user.
type SendTransaction ¶
type SendTransaction struct {
// contains filtered or unexported fields
}
func NewSendTransaction ¶
func NewSendTransaction(pipeline Pipeline, nodeSelector node.Selector, sessions *Sessions) *SendTransaction
type SendTransactionParams ¶
type SendTransactionResult ¶
type SendTransactionResult struct { ReceivedAt time.Time `json:"receivedAt"` SentAt time.Time `json:"sentAt"` TxHash string `json:"transactionHash"` Tx *commandspb.Transaction `json:"transaction"` }
type SessionListKeys ¶ added in v0.55.0
type SessionListKeys struct {
// contains filtered or unexported fields
}
func NewListKeys ¶
func NewListKeys(sessions *Sessions) *SessionListKeys
type SessionListKeysParams ¶ added in v0.55.0
type SessionListKeysParams struct {
Token string `json:"token"`
}
type SessionListKeysResult ¶ added in v0.55.0
type SessionListKeysResult struct {
Keys []SessionNamedPublicKey `json:"keys"`
}
type SessionNamedPublicKey ¶ added in v0.55.0
type Sessions ¶
type Sessions struct {
// contains filtered or unexported fields
}
func NewSessions ¶
func NewSessions() *Sessions
func (*Sessions) ConnectWallet ¶
ConnectWallet initiates a wallet connection and load associated resources in it. If a connection already exists, it's disconnected and a new token is generated.
func (*Sessions) DisconnectWallet ¶
DisconnectWallet unloads the connected wallet resources and revokes the token. It does not fail. Non-existing token does nothing.
func (*Sessions) GetConnectedWallet ¶
func (s *Sessions) GetConnectedWallet(token string) (*ConnectedWallet, error)
GetConnectedWallet retrieves the resources and information of the connected wallet, associated to the specified token.
type SignTransaction ¶ added in v0.55.0
type SignTransaction struct {
// contains filtered or unexported fields
}
func NewSignTransaction ¶ added in v0.55.0
func NewSignTransaction(pipeline Pipeline, nodeSelector node.Selector, sessions *Sessions) *SignTransaction
type SignTransactionParams ¶ added in v0.55.0
type SignTransactionResult ¶ added in v0.55.0
type SignTransactionResult struct {
Tx *commandspb.Transaction `json:"transaction"`
}
type WalletStore ¶
type WalletStore interface { WalletExists(ctx context.Context, name string) (bool, error) GetWallet(ctx context.Context, name, passphrase string) (wallet.Wallet, error) ListWallets(ctx context.Context) ([]string, error) SaveWallet(ctx context.Context, w wallet.Wallet, passphrase string) error DeleteWallet(ctx context.Context, name string) error GetWalletPath(name string) string }
WalletStore is the component used to retrieve and update wallets from the computer.
Source Files ¶
- admin_annotate_key.go
- admin_create_wallet.go
- admin_describe_key.go
- admin_describe_network.go
- admin_describe_permissions.go
- admin_describe_wallet.go
- admin_generate_key.go
- admin_import_network.go
- admin_import_wallet.go
- admin_isolate_key.go
- admin_list_key.go
- admin_list_networks.go
- admin_list_permissions.go
- admin_list_wallets.go
- admin_purge_permissions.go
- admin_remove_network.go
- admin_remove_wallet.go
- admin_revoke_permissions.go
- admin_rotate_key.go
- admin_send_transaction.go
- admin_sign_message.go
- admin_sign_transaction.go
- admin_taint_key.go
- admin_untaint_key.go
- admin_update_network.go
- admin_update_permissions.go
- admin_verify_message.go
- api.go
- context.go
- doc.go
- errors.go
- session_connect_wallet.go
- session_disconnect_wallet.go
- session_get_chain_id.go
- session_get_permissions.go
- session_list_keys.go
- session_request_permissions.go
- session_send_transaction.go
- session_sign_transaction.go
- sessions.go