api

package
v0.0.0-...-589da53 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WalletConnectionSuccessfullyEstablished = "The connection to the wallet has been successfully established."
	PassphraseRequestReasonUnlockWallet     = "The application wants to unlock the wallet."
)
View Source
const (

	// ErrorCodeRequestHasBeenInterrupted refers to a request that has been
	// interrupted by the server or the third-party application. It could
	// originate from a timeout or an explicit cancellation.
	ErrorCodeRequestHasBeenInterrupted jsonrpc.ErrorCode = -32001

	// ErrorCodeHostnameResolutionFailure refers to the inability for the server
	// to resolve the hostname from the request.
	ErrorCodeHostnameResolutionFailure jsonrpc.ErrorCode = -32002

	// ErrorCodeAuthenticationFailure refers to a request that have authentication
	// problems.
	ErrorCodeAuthenticationFailure jsonrpc.ErrorCode = -32003

	// ErrorCodeNodeCommunicationFailed refers to the inability of the program to
	// talk to the network nodes.
	ErrorCodeNodeCommunicationFailed jsonrpc.ErrorCode = 1000

	// ErrorCodeNetworkRejectedTransaction refers to a transaction rejected by
	// the network nodes but for an unknown ABCI code.
	ErrorCodeNetworkRejectedTransaction jsonrpc.ErrorCode = 1001

	// ErrorCodeNetworkRejectedInvalidTransaction refers to a validation failure raised
	// by the network nodes (error code 51).
	ErrorCodeNetworkRejectedInvalidTransaction jsonrpc.ErrorCode = 1051

	// ErrorCodeNetworkRejectedMalformedTransaction refers to the inability to
	// decode a transaction from the network nodes (error code 60).
	ErrorCodeNetworkRejectedMalformedTransaction jsonrpc.ErrorCode = 1060

	// ErrorCodeNetworkCouldNotProcessTransaction refers to the inability to
	// process a transaction from the network nodes (error code 70).
	ErrorCodeNetworkCouldNotProcessTransaction jsonrpc.ErrorCode = 1070

	// ErrorCodeNetworkRejectedUnsupportedTransaction is raised when the network
	// nodes encounter an unsupported transaction (error code 80).
	ErrorCodeNetworkRejectedUnsupportedTransaction jsonrpc.ErrorCode = 1080

	// ErrorCodeNetworkSpamProtectionActivated is raised when the network
	// nodes spin up the spam protection mechanism (error code 89).
	ErrorCodeNetworkSpamProtectionActivated jsonrpc.ErrorCode = 1089

	// ErrorCodeRequestNotPermitted refers a request made by a third-party application
	// that is not permitted to do. This error is related to the permissions'
	// system.
	ErrorCodeRequestNotPermitted jsonrpc.ErrorCode = 2000

	// ErrorCodeRequestHasBeenCancelledByApplication refers to an automated
	// cancellation of a request by the application core. This happens when some
	// requirements are missing to ensure correct handling of a request.
	ErrorCodeRequestHasBeenCancelledByApplication jsonrpc.ErrorCode = 2001

	// 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. When received, the third-party application should
	// consider the user has withdrawn from the action, and thus, abort the
	// action.
	ErrorCodeRequestHasBeenRejected jsonrpc.ErrorCode = 3001

	// ErrorCodeRequestHasBeenCancelledByUser refers to a cancellation of a
	// request by the user. It's conceptually different from a rejection.
	// Contrary to a rejection, when a cancellation is received, the third-party
	// application should temporarily back off, maintain its state, and wait for
	// the user to be ready to continue.
	ErrorCodeRequestHasBeenCancelledByUser jsonrpc.ErrorCode = 3002
)
View Source
const FileSchemePrefix = "file://"

FileSchemePrefix defines the prefix used in URL's to indicate that the string represents a file-path.

View Source
const PermissionsSuccessfullyUpdated = "The permissions have been successfully updated."
View Source
const TransactionSuccessfullyChecked = "The transaction has been successfully checked."
View Source
const TransactionSuccessfullySigned = "The transaction has been successfully signed."

Variables

View Source
var (
	ErrApplicationCancelledTheRequest                     = errors.New("the application cancelled the request")
	ErrBlockHashIsRequired                                = errors.New("the block hash is required")
	ErrBlockHeightIsRequired                              = errors.New("the block height is required")
	ErrBlockHeightTooHistoric                             = errors.New("the block height is too historic")
	ErrCannotRotateKeysOnIsolatedWallet                   = errors.New("cannot rotate keys on an isolated wallet")
	ErrChainIDIsRequired                                  = errors.New("the chain ID is required")
	ErrConnectionClosed                                   = errors.New("the connection has been closed")
	ErrCouldNotCheckTransaction                           = errors.New("could not check transaction")
	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")
	ErrCouldNotListKeys                                   = errors.New("could not list the keys")
	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")
	ErrIsolatedWalletPassphraseIsRequired                 = errors.New("the isolated wallet passphrase is required")
	ErrLastBlockDataOrNetworkIsRequired                   = errors.New("a network or the last block data is required")
	ErrMessageIsRequired                                  = errors.New("the message is required")
	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")
	ErrNewNameIsRequired                                  = errors.New("the new name is required")
	ErrNewPassphraseIsRequired                            = errors.New("the new passphrase 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")
	ErrNoWalletToConnectTo                                = errors.New("there is no wallet to connect to, you should, first, create or import a wallet")
	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("this public key is not allowed to be used")
	ErrPublicKeyIsRequired                                = errors.New("the public key is required")
	ErrRawTransactionIsNotValidFuryTransaction            = errors.New("the raw transaction is not a valid Fury transaction")
	ErrRecoveryPhraseIsRequired                           = errors.New("the recovery phrase is required")
	ErrRequestCancelled                                   = errors.New("the request has been cancelled")
	ErrRequestInterrupted                                 = errors.New("the request has been interrupted")
	ErrSendingModeCannotBeTypeUnspecified                 = errors.New(`the sending mode can't be "TYPE_UNSPECIFIED"`)
	ErrSendingModeIsRequired                              = errors.New("the sending mode is required")
	ErrSignatureIsRequired                                = errors.New("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")
	ErrTransactionIsNotValidJSON                          = errors.New("the transaction is not valid JSON")
	ErrTransactionIsRequired                              = errors.New("the transaction is required")
	ErrTransactionsPerBlockLimitReached                   = errors.New("the transaction per block limit has been reached")
	ErrUserCancelledTheRequest                            = errors.New("the user cancelled the request")
	ErrUserCloseTheConnection                             = errors.New("the user closed the connection")
	ErrUserRejectedAccessToKeys                           = errors.New("the user rejected the access to the keys")
	ErrUserRejectedCheckingOfTransaction                  = errors.New("the user rejected the checking of the transaction")
	ErrUserRejectedSendingOfTransaction                   = errors.New("the user rejected the sending of the transaction")
	ErrUserRejectedSigningOfTransaction                   = errors.New("the user rejected the signing of the transaction")
	ErrUserRejectedWalletConnection                       = errors.New("the user rejected the wallet connection")
	ErrWalletAlreadyExists                                = errors.New("a wallet with the same name already exists")
	ErrWalletDoesNotExist                                 = errors.New("the wallet does not exist")
	ErrWalletIsLocked                                     = errors.New("the wallet is locked")
	ErrWalletIsRequired                                   = errors.New("the wallet is required")
	ErrWalletKeyDerivationVersionIsRequired               = errors.New("the wallet key derivation version is required")
	ErrWrongPassphrase                                    = errors.New("wrong passphrase")
)
View Source
var (
	ErrInvalidNetworkSource = errors.New("invalid network source")
)

Functions

func AdminAPI

func AdminAPI(
	log *zap.Logger,
	walletStore WalletStore,
	netStore NetworkStore,
	nodeSelectorBuilder NodeSelectorBuilder,
	connectionsManager ConnectionsManager,
) (*jsonrpc.Dispatcher, 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 ApplicationCancellationError

func ApplicationCancellationError(err error) *jsonrpc.ErrorDetails

func ApplicationError

func ApplicationError(code jsonrpc.ErrorCode, err error) *jsonrpc.ErrorDetails

func ConnectionClosedError

func ConnectionClosedError(err error) *jsonrpc.ErrorDetails

func HandleRequestFlowError

func HandleRequestFlowError(ctx context.Context, traceID string, interactor Interactor, err error) *jsonrpc.ErrorDetails

HandleRequestFlowError is a generic function that build the appropriate API error response based on the underlying error. If none of them matches, the error handling is delegating to the caller.

func InternalError

func InternalError(err error) *jsonrpc.ErrorDetails

func InvalidParams

func InvalidParams(err error) *jsonrpc.ErrorDetails

func NetworkError

func NetworkError(code jsonrpc.ErrorCode, err error) *jsonrpc.ErrorDetails

func NetworkErrorFromTransactionError

func NetworkErrorFromTransactionError(err error) *jsonrpc.ErrorDetails

NetworkErrorFromTransactionError returns an error with a generic message but a specialized code. This is intended to give a coarse-grained indication to the third-party application without taking any risk of leaking information from the error message.

func NodeCommunicationError

func NodeCommunicationError(err error) *jsonrpc.ErrorDetails

func RequestInterruptedError

func RequestInterruptedError(err error) *jsonrpc.ErrorDetails

func RequestNotPermittedError

func RequestNotPermittedError(err error) *jsonrpc.ErrorDetails

func UserCancellationError

func UserCancellationError(err error) *jsonrpc.ErrorDetails

func UserError

func UserError(code jsonrpc.ErrorCode, err error) *jsonrpc.ErrorDetails

func UserRejectionError

func UserRejectionError(err error) *jsonrpc.ErrorDetails

Types

type AdminAPIConfig

type AdminAPIConfig struct {
	GRPC    AdminGRPCConfig    `json:"grpc"`
	REST    AdminRESTConfig    `json:"rest"`
	GraphQL AdminGraphQLConfig `json:"graphQL"`
}

type AdminAnnotateKey

type AdminAnnotateKey struct {
	// contains filtered or unexported fields
}

func NewAdminAnnotateKey

func NewAdminAnnotateKey(
	walletStore WalletStore,
) *AdminAnnotateKey

func (*AdminAnnotateKey) Handle

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

type AdminAnnotateKeyParams struct {
	Wallet    string            `json:"wallet"`
	PublicKey string            `json:"publicKey"`
	Metadata  []wallet.Metadata `json:"metadata"`
}

type AdminAnnotateKeyResult

type AdminAnnotateKeyResult struct {
	Metadata []wallet.Metadata `json:"metadata"`
}

type AdminAppConfig

type AdminAppConfig struct {
	Explorer   string `json:"explorer"`
	Console    string `json:"console"`
	Governance string `json:"governance"`
}

type AdminCheckTransaction

type AdminCheckTransaction struct {
	// contains filtered or unexported fields
}

func NewAdminCheckTransaction

func NewAdminCheckTransaction(
	walletStore WalletStore, networkStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder,
) *AdminCheckTransaction

func (*AdminCheckTransaction) Handle

type AdminCheckTransactionParams

type AdminCheckTransactionParams struct {
	Wallet                 string        `json:"wallet"`
	PublicKey              string        `json:"publicKey"`
	Network                string        `json:"network"`
	NodeAddress            string        `json:"nodeAddress"`
	Retries                uint64        `json:"retries"`
	MaximumRequestDuration time.Duration `json:"maximumRequestDuration"`
	Transaction            interface{}   `json:"transaction"`
}

type AdminCheckTransactionResult

type AdminCheckTransactionResult struct {
	ReceivedAt         time.Time               `json:"receivedAt"`
	SentAt             time.Time               `json:"sentAt"`
	Transaction        *commandspb.Transaction `json:"transaction"`
	Node               AdminNodeInfoResult     `json:"node"`
	EncodedTransaction string                  `json:"encodedTransaction"`
}

type AdminCloseConnection

type AdminCloseConnection struct {
	// contains filtered or unexported fields
}

func NewAdminCloseConnection

func NewAdminCloseConnection(connectionsManager ConnectionsManager) *AdminCloseConnection

func (*AdminCloseConnection) Handle

Handle closes the connection between a third-party application and a wallet opened in the service that run against the specified network. It does not fail if the service or the connection are already closed.

type AdminCloseConnectionParams

type AdminCloseConnectionParams struct {
	Hostname string `json:"hostname"`
	Wallet   string `json:"wallet"`
}

type AdminCloseConnectionsToHostname

type AdminCloseConnectionsToHostname struct {
	// contains filtered or unexported fields
}

func NewAdminCloseConnectionsToHostname

func NewAdminCloseConnectionsToHostname(connectionsManager ConnectionsManager) *AdminCloseConnectionsToHostname

func (*AdminCloseConnectionsToHostname) Handle

Handle closes all the connections from the specified hostname to any wallet opened in the service that run against the specified network. It does not fail if the service or the connections are already closed.

type AdminCloseConnectionsToHostnameParams

type AdminCloseConnectionsToHostnameParams struct {
	Hostname string `json:"hostname"`
}

type AdminCloseConnectionsToWallet

type AdminCloseConnectionsToWallet struct {
	// contains filtered or unexported fields
}

func NewAdminCloseConnectionsToWallet

func NewAdminCloseConnectionsToWallet(connectionsManager ConnectionsManager) *AdminCloseConnectionsToWallet

func (*AdminCloseConnectionsToWallet) Handle

Handle closes all the connections from any hostname to the specified wallet opened in the service that run against the specified network. It does not fail if the service or the connections are already closed.

type AdminCloseConnectionsToWalletParams

type AdminCloseConnectionsToWalletParams struct {
	Wallet string `json:"wallet"`
}

type AdminCreateWallet

type AdminCreateWallet struct {
	// contains filtered or unexported fields
}

func NewAdminCreateWallet

func NewAdminCreateWallet(
	walletStore WalletStore,
) *AdminCreateWallet

func (*AdminCreateWallet) Handle

Handle creates a wallet and generates its first key.

type AdminCreateWalletParams

type AdminCreateWalletParams struct {
	Wallet     string `json:"wallet"`
	Passphrase string `json:"passphrase"`
}

type AdminCreateWalletResult

type AdminCreateWalletResult struct {
	Wallet AdminCreatedWallet  `json:"wallet"`
	Key    AdminFirstPublicKey `json:"key"`
}

type AdminCreatedWallet

type AdminCreatedWallet struct {
	Name                 string `json:"name"`
	KeyDerivationVersion uint32 `json:"keyDerivationVersion"`
	RecoveryPhrase       string `json:"recoveryPhrase"`
}

type AdminDescribeKey

type AdminDescribeKey struct {
	// contains filtered or unexported fields
}

func NewAdminDescribeKey

func NewAdminDescribeKey(
	walletStore WalletStore,
) *AdminDescribeKey

func (*AdminDescribeKey) Handle

Handle retrieves key's information.

type AdminDescribeKeyParams

type AdminDescribeKeyParams struct {
	Wallet    string `json:"wallet"`
	PublicKey string `json:"publicKey"`
}

type AdminDescribeKeyResult

type AdminDescribeKeyResult struct {
	PublicKey string            `json:"publicKey"`
	Name      string            `json:"name"`
	Algorithm wallet.Algorithm  `json:"algorithm"`
	Metadata  []wallet.Metadata `json:"metadata"`
	IsTainted bool              `json:"isTainted"`
}

type AdminDescribeNetwork

type AdminDescribeNetwork struct {
	// contains filtered or unexported fields
}

func NewAdminDescribeNetwork

func NewAdminDescribeNetwork(
	networkStore NetworkStore,
) *AdminDescribeNetwork

func (*AdminDescribeNetwork) Handle

type AdminDescribeNetworkParams

type AdminDescribeNetworkParams struct {
	Name string `json:"name"`
}

type AdminDescribePermissions

type AdminDescribePermissions struct {
	// contains filtered or unexported fields
}

func NewAdminDescribePermissions

func NewAdminDescribePermissions(
	walletStore WalletStore,
) *AdminDescribePermissions

func (*AdminDescribePermissions) Handle

Handle retrieves permissions set for the specified wallet and hostname.

type AdminDescribePermissionsParams

type AdminDescribePermissionsParams struct {
	Wallet   string `json:"wallet"`
	Hostname string `json:"hostname"`
}

type AdminDescribePermissionsResult

type AdminDescribePermissionsResult struct {
	Permissions wallet.Permissions `json:"permissions"`
}

type AdminDescribeWallet

type AdminDescribeWallet struct {
	// contains filtered or unexported fields
}

func NewAdminDescribeWallet

func NewAdminDescribeWallet(
	walletStore WalletStore,
) *AdminDescribeWallet

func (*AdminDescribeWallet) Handle

type AdminDescribeWalletParams

type AdminDescribeWalletParams struct {
	Wallet string `json:"wallet"`
}

type AdminDescribeWalletResult

type AdminDescribeWalletResult struct {
	Name                 string `json:"name"`
	ID                   string `json:"id"`
	Type                 string `json:"type"`
	KeyDerivationVersion uint32 `json:"keyDerivationVersion"`
}

type AdminFirstPublicKey

type AdminFirstPublicKey struct {
	PublicKey string            `json:"publicKey"`
	Algorithm wallet.Algorithm  `json:"algorithm"`
	Metadata  []wallet.Metadata `json:"metadata"`
}

type AdminGRPCConfig

type AdminGRPCConfig struct {
	Hosts []string `json:"hosts"`
}

type AdminGenerateKey

type AdminGenerateKey struct {
	// contains filtered or unexported fields
}

func NewAdminGenerateKey

func NewAdminGenerateKey(
	walletStore WalletStore,
) *AdminGenerateKey

func (*AdminGenerateKey) Handle

Handle generates a key on the specified wallet.

type AdminGenerateKeyParams

type AdminGenerateKeyParams struct {
	Wallet   string            `json:"wallet"`
	Metadata []wallet.Metadata `json:"metadata"`
}

type AdminGenerateKeyResult

type AdminGenerateKeyResult struct {
	PublicKey string            `json:"publicKey"`
	Algorithm wallet.Algorithm  `json:"algorithm"`
	Metadata  []wallet.Metadata `json:"metadata"`
}

type AdminGraphQLConfig

type AdminGraphQLConfig struct {
	Hosts []string `json:"hosts"`
}

type AdminImportNetwork

type AdminImportNetwork struct {
	// contains filtered or unexported fields
}

func NewAdminImportNetwork

func NewAdminImportNetwork(
	networkStore NetworkStore,
) *AdminImportNetwork

func (*AdminImportNetwork) Handle

type AdminImportNetworkParams

type AdminImportNetworkParams struct {
	Name      string `json:"name"`
	URL       string `json:"url"`
	Overwrite bool   `json:"overwrite"`
}

type AdminImportNetworkResult

type AdminImportNetworkResult struct {
	Name string `json:"name"`
}

type AdminImportWallet

type AdminImportWallet struct {
	// contains filtered or unexported fields
}

func NewAdminImportWallet

func NewAdminImportWallet(
	walletStore WalletStore,
) *AdminImportWallet

func (*AdminImportWallet) Handle

type AdminImportWalletParams

type AdminImportWalletParams struct {
	Wallet               string `json:"wallet"`
	RecoveryPhrase       string `json:"recoveryPhrase"`
	KeyDerivationVersion uint32 `json:"keyDerivationVersion"`
	Passphrase           string `json:"passphrase"`
}

type AdminImportWalletResult

type AdminImportWalletResult struct {
	Wallet AdminImportedWallet `json:"wallet"`
	Key    AdminFirstPublicKey `json:"key"`
}

type AdminImportedWallet

type AdminImportedWallet struct {
	Name                 string `json:"name"`
	KeyDerivationVersion uint32 `json:"keyDerivationVersion"`
}

type AdminIsolateKey

type AdminIsolateKey struct {
	// contains filtered or unexported fields
}

func NewAdminIsolateKey

func NewAdminIsolateKey(
	walletStore WalletStore,
) *AdminIsolateKey

func (*AdminIsolateKey) Handle

Handle isolates a key in a specific wallet.

type AdminIsolateKeyParams

type AdminIsolateKeyParams struct {
	Wallet                   string `json:"wallet"`
	PublicKey                string `json:"publicKey"`
	IsolatedWalletPassphrase string `json:"isolatedWalletPassphrase"`
}

type AdminIsolateKeyResult

type AdminIsolateKeyResult struct {
	Wallet string `json:"wallet"`
}

type AdminLastBlockData

type AdminLastBlockData struct {
	ChainID                 string `json:"chainID"`
	BlockHeight             uint64 `json:"blockHeight"`
	BlockHash               string `json:"blockHash"`
	ProofOfWorkHashFunction string `json:"proofOfWorkHashFunction"`
	ProofOfWorkDifficulty   uint32 `json:"proofOfWorkDifficulty"`
}

type AdminListConnections

type AdminListConnections struct {
	// contains filtered or unexported fields
}

func NewAdminListConnections

func NewAdminListConnections(connectionsManager ConnectionsManager) *AdminListConnections

func (*AdminListConnections) Handle

type AdminListConnectionsResult

type AdminListConnectionsResult struct {
	ActiveConnections []Connection `json:"activeConnections"`
}

type AdminListKeys

type AdminListKeys struct {
	// contains filtered or unexported fields
}

func NewAdminListKeys

func NewAdminListKeys(
	walletStore WalletStore,
) *AdminListKeys

func (*AdminListKeys) Handle

type AdminListKeysParams

type AdminListKeysParams struct {
	Wallet string `json:"wallet"`
}

type AdminListKeysResult

type AdminListKeysResult struct {
	Keys []AdminNamedPublicKey `json:"keys"`
}

type AdminListNetworkResult

type AdminListNetworkResult struct {
	Name     string             `json:"name"`
	Metadata []network.Metadata `json:"metadata"`
}

type AdminListNetworks

type AdminListNetworks struct {
	// contains filtered or unexported fields
}

func NewAdminListNetworks

func NewAdminListNetworks(
	networkStore NetworkStore,
) *AdminListNetworks

func (*AdminListNetworks) Handle

Handle List all registered networks.

type AdminListNetworksResult

type AdminListNetworksResult struct {
	Networks []AdminListNetworkResult `json:"networks"`
}

type AdminListPermissions

type AdminListPermissions struct {
	// contains filtered or unexported fields
}

func NewAdminListPermissions

func NewAdminListPermissions(
	walletStore WalletStore,
) *AdminListPermissions

func (*AdminListPermissions) Handle

Handle returns the permissions summary for all set hostnames.

type AdminListPermissionsParams

type AdminListPermissionsParams struct {
	Wallet string `json:"wallet"`
}

type AdminListPermissionsResult

type AdminListPermissionsResult struct {
	Permissions map[string]wallet.PermissionsSummary `json:"permissions"`
}

type AdminListWallets

type AdminListWallets struct {
	// contains filtered or unexported fields
}

func NewAdminListWallets

func NewAdminListWallets(
	walletStore WalletStore,
) *AdminListWallets

func (*AdminListWallets) Handle

Handle list all the wallets present on the computer.

type AdminListWalletsResult

type AdminListWalletsResult struct {
	Wallets []string `json:"wallets"`
}

type AdminNamedPublicKey

type AdminNamedPublicKey struct {
	Name      string `json:"name"`
	PublicKey string `json:"publicKey"`
}

type AdminNetwork

type AdminNetwork struct {
	Name     string             `json:"name"`
	Metadata []network.Metadata `json:"metadata"`
	API      AdminAPIConfig     `json:"api"`
	Apps     AdminAppConfig     `json:"apps"`
}

type AdminNodeInfoResult

type AdminNodeInfoResult struct {
	Host string `json:"host"`
}

type AdminPurgePermissions

type AdminPurgePermissions struct {
	// contains filtered or unexported fields
}

func NewAdminPurgePermissions

func NewAdminPurgePermissions(
	walletStore WalletStore,
) *AdminPurgePermissions

func (*AdminPurgePermissions) Handle

Handle purges all the permissions set for all hostname.

type AdminPurgePermissionsParams

type AdminPurgePermissionsParams struct {
	Wallet string `json:"wallet"`
}

type AdminRESTConfig

type AdminRESTConfig struct {
	Hosts []string `json:"hosts"`
}

type AdminRemoveNetwork

type AdminRemoveNetwork struct {
	// contains filtered or unexported fields
}

func NewAdminRemoveNetwork

func NewAdminRemoveNetwork(
	networkStore NetworkStore,
) *AdminRemoveNetwork

func (*AdminRemoveNetwork) Handle

Handle removes a wallet from the computer.

type AdminRemoveNetworkParams

type AdminRemoveNetworkParams struct {
	Name string `json:"name"`
}

type AdminRemoveWallet

type AdminRemoveWallet struct {
	// contains filtered or unexported fields
}

func NewAdminRemoveWallet

func NewAdminRemoveWallet(
	walletStore WalletStore,
) *AdminRemoveWallet

func (*AdminRemoveWallet) Handle

Handle removes a wallet from the computer.

type AdminRemoveWalletParams

type AdminRemoveWalletParams struct {
	Wallet string `json:"wallet"`
}

type AdminRenameNetwork

type AdminRenameNetwork struct {
	// contains filtered or unexported fields
}

func NewAdminRenameNetwork

func NewAdminRenameNetwork(
	networkStore NetworkStore,
) *AdminRenameNetwork

func (*AdminRenameNetwork) Handle

Handle renames a network.

type AdminRenameNetworkParams

type AdminRenameNetworkParams struct {
	Network string `json:"network"`
	NewName string `json:"newName"`
}

type AdminRenameWallet

type AdminRenameWallet struct {
	// contains filtered or unexported fields
}

func NewAdminRenameWallet

func NewAdminRenameWallet(
	walletStore WalletStore,
) *AdminRenameWallet

func (*AdminRenameWallet) Handle

Handle renames a wallet.

type AdminRenameWalletParams

type AdminRenameWalletParams struct {
	Wallet  string `json:"wallet"`
	NewName string `json:"newName"`
}

type AdminRevokePermissions

type AdminRevokePermissions struct {
	// contains filtered or unexported fields
}

func NewAdminRevokePermissions

func NewAdminRevokePermissions(
	walletStore WalletStore,
) *AdminRevokePermissions

func (*AdminRevokePermissions) Handle

Handle revokes the permissions set on the specified hostname.

type AdminRevokePermissionsParams

type AdminRevokePermissionsParams struct {
	Wallet   string `json:"wallet"`
	Hostname string `json:"hostname"`
}

type AdminRotateKey

type AdminRotateKey struct {
	// contains filtered or unexported fields
}

func NewAdminRotateKey

func NewAdminRotateKey(
	walletStore WalletStore,
) *AdminRotateKey

func (*AdminRotateKey) Handle

Handle create a transaction to rotate the keys.

type AdminRotateKeyParams

type AdminRotateKeyParams struct {
	Wallet                string `json:"wallet"`
	FromPublicKey         string `json:"fromPublicKey"`
	ToPublicKey           string `json:"toPublicKey"`
	ChainID               string `json:"chainID"`
	SubmissionBlockHeight uint64 `json:"submissionBlockHeight"`
	EnactmentBlockHeight  uint64 `json:"enactmentBlockHeight"`
}

type AdminRotateKeyResult

type AdminRotateKeyResult struct {
	MasterPublicKey    string `json:"masterPublicKey"`
	EncodedTransaction string `json:"encodedTransaction"`
}

type AdminSendRawTransaction

type AdminSendRawTransaction struct {
	// contains filtered or unexported fields
}

func NewAdminSendRawTransaction

func NewAdminSendRawTransaction(networkStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder) *AdminSendRawTransaction

func (*AdminSendRawTransaction) Handle

type AdminSendRawTransactionNodeResult

type AdminSendRawTransactionNodeResult struct {
	Host string `json:"host"`
}

type AdminSendRawTransactionParams

type AdminSendRawTransactionParams struct {
	Network                string        `json:"network"`
	NodeAddress            string        `json:"nodeAddress"`
	Retries                uint64        `json:"retries"`
	MaximumRequestDuration time.Duration `json:"maximumRequestDuration"`
	SendingMode            string        `json:"sendingMode"`
	EncodedTransaction     string        `json:"encodedTransaction"`
}

type AdminSendRawTransactionResult

type AdminSendRawTransactionResult struct {
	ReceivedAt      time.Time                         `json:"receivedAt"`
	SentAt          time.Time                         `json:"sentAt"`
	TransactionHash string                            `json:"transactionHash"`
	Transaction     *commandspb.Transaction           `json:"transaction"`
	Node            AdminSendRawTransactionNodeResult `json:"node"`
}

type AdminSendTransaction

type AdminSendTransaction struct {
	// contains filtered or unexported fields
}

func NewAdminSendTransaction

func NewAdminSendTransaction(walletStore WalletStore, networkStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder) *AdminSendTransaction

func (*AdminSendTransaction) Handle

type AdminSendTransactionParams

type AdminSendTransactionParams struct {
	Wallet                 string        `json:"wallet"`
	PublicKey              string        `json:"publicKey"`
	Network                string        `json:"network"`
	NodeAddress            string        `json:"nodeAddress"`
	Retries                uint64        `json:"retries"`
	MaximumRequestDuration time.Duration `json:"maximumRequestDuration"`
	SendingMode            string        `json:"sendingMode"`
	Transaction            interface{}   `json:"transaction"`
}

type AdminSendTransactionResult

type AdminSendTransactionResult struct {
	ReceivedAt      time.Time               `json:"receivedAt"`
	SentAt          time.Time               `json:"sentAt"`
	TransactionHash string                  `json:"transactionHash"`
	Transaction     *commandspb.Transaction `json:"transaction"`
	Node            AdminNodeInfoResult     `json:"node"`
}

type AdminSignMessage

type AdminSignMessage struct {
	// contains filtered or unexported fields
}

func NewAdminSignMessage

func NewAdminSignMessage(walletStore WalletStore) *AdminSignMessage

func (*AdminSignMessage) Handle

type AdminSignMessageParams

type AdminSignMessageParams struct {
	Wallet         string `json:"wallet"`
	PublicKey      string `json:"publicKey"`
	EncodedMessage string `json:"encodedMessage"`
}

type AdminSignMessageResult

type AdminSignMessageResult struct {
	EncodedSignature string `json:"encodedSignature"`
}

type AdminSignTransaction

type AdminSignTransaction struct {
	// contains filtered or unexported fields
}

func NewAdminSignTransaction

func NewAdminSignTransaction(walletStore WalletStore, networkStore NetworkStore, nodeSelectorBuilder NodeSelectorBuilder) *AdminSignTransaction

func (*AdminSignTransaction) Handle

type AdminSignTransactionParams

type AdminSignTransactionParams struct {
	Wallet                 string              `json:"wallet"`
	PublicKey              string              `json:"publicKey"`
	Network                string              `json:"network"`
	Transaction            interface{}         `json:"transaction"`
	Retries                uint64              `json:"retries"`
	MaximumRequestDuration time.Duration       `json:"maximumRequestDuration"`
	LastBlockData          *AdminLastBlockData `json:"lastBlockData"`
}

type AdminSignTransactionResult

type AdminSignTransactionResult struct {
	Transaction        *commandspb.Transaction `json:"transaction"`
	EncodedTransaction string                  `json:"encodedTransaction"`
}

type AdminTaintKey

type AdminTaintKey struct {
	// contains filtered or unexported fields
}

func NewAdminTaintKey

func NewAdminTaintKey(
	walletStore WalletStore,
) *AdminTaintKey

func (*AdminTaintKey) Handle

Handle marks the specified public key as tainted. It makes it unusable for transaction signing and sending.

type AdminTaintKeyParams

type AdminTaintKeyParams struct {
	Wallet    string `json:"wallet"`
	PublicKey string `json:"publicKey"`
}

type AdminUnlockWallet

type AdminUnlockWallet struct {
	// contains filtered or unexported fields
}

func NewAdminUnlockWallet

func NewAdminUnlockWallet(
	walletStore WalletStore,
) *AdminUnlockWallet

func (*AdminUnlockWallet) Handle

type AdminUnlockWalletParams

type AdminUnlockWalletParams struct {
	Wallet     string `json:"wallet"`
	Passphrase string `json:"passphrase"`
}

type AdminUntaintKey

type AdminUntaintKey struct {
	// contains filtered or unexported fields
}

func NewAdminUntaintKey

func NewAdminUntaintKey(
	walletStore WalletStore,
) *AdminUntaintKey

func (*AdminUntaintKey) Handle

Handle marks the specified public key as tainted. It makes it unusable for transaction signing.

type AdminUntaintKeyParams

type AdminUntaintKeyParams struct {
	Wallet    string `json:"wallet"`
	PublicKey string `json:"publicKey"`
}

type AdminUpdateNetwork

type AdminUpdateNetwork struct {
	// contains filtered or unexported fields
}

func NewAdminUpdateNetwork

func NewAdminUpdateNetwork(
	networkStore NetworkStore,
) *AdminUpdateNetwork

func (*AdminUpdateNetwork) Handle

type AdminUpdatePassphrase

type AdminUpdatePassphrase struct {
	// contains filtered or unexported fields
}

func NewAdminUpdatePassphrase

func NewAdminUpdatePassphrase(
	walletStore WalletStore,
) *AdminUpdatePassphrase

func (*AdminUpdatePassphrase) Handle

type AdminUpdatePassphraseParams

type AdminUpdatePassphraseParams struct {
	Wallet        string `json:"wallet"`
	NewPassphrase string `json:"newPassphrase"`
}

type AdminUpdatePermissions

type AdminUpdatePermissions struct {
	// contains filtered or unexported fields
}

func NewAdminUpdatePermissions

func NewAdminUpdatePermissions(
	walletStore WalletStore,
) *AdminUpdatePermissions

func (*AdminUpdatePermissions) Handle

type AdminUpdatePermissionsParams

type AdminUpdatePermissionsParams struct {
	Wallet      string             `json:"wallet"`
	Hostname    string             `json:"hostname"`
	Permissions wallet.Permissions `json:"permissions"`
}

type AdminUpdatePermissionsResult

type AdminUpdatePermissionsResult struct {
	Permissions wallet.Permissions `json:"permissions"`
}

type AdminVerifyMessage

type AdminVerifyMessage struct{}

func NewAdminVerifyMessage

func NewAdminVerifyMessage() *AdminVerifyMessage

func (*AdminVerifyMessage) Handle

type AdminVerifyMessageParams

type AdminVerifyMessageParams struct {
	PublicKey        string `json:"publicKey"`
	EncodedMessage   string `json:"encodedMessage"`
	EncodedSignature string `json:"encodedSignature"`
}

type AdminVerifyMessageResult

type AdminVerifyMessageResult struct {
	IsValid bool `json:"isValid"`
}

type AllowedKey

type AllowedKey struct {
	// contains filtered or unexported fields
}

func (AllowedKey) Name

func (r AllowedKey) Name() string

func (AllowedKey) PublicKey

func (r AllowedKey) PublicKey() string

type ClientAPI

type ClientAPI struct {
	// contains filtered or unexported fields
}

func BuildClientAPI

func BuildClientAPI(walletStore WalletStore, interactor Interactor, nodeSelector node.Selector, spam SpamHandler) (*ClientAPI, error)

func (*ClientAPI) CheckTransaction

func (a *ClientAPI) CheckTransaction(ctx context.Context, rawParams jsonrpc.Params, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

func (*ClientAPI) ConnectWallet

func (a *ClientAPI) ConnectWallet(ctx context.Context, hostname string) (wallet.Wallet, *jsonrpc.ErrorDetails)

func (*ClientAPI) GetChainID

func (a *ClientAPI) GetChainID(ctx context.Context) (jsonrpc.Result, *jsonrpc.ErrorDetails)

func (*ClientAPI) ListKeys

func (a *ClientAPI) ListKeys(ctx context.Context, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

func (*ClientAPI) SendTransaction

func (a *ClientAPI) SendTransaction(ctx context.Context, rawParams jsonrpc.Params, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

func (*ClientAPI) SignTransaction

func (a *ClientAPI) SignTransaction(ctx context.Context, rawParams jsonrpc.Params, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

type ClientCheckTransaction

type ClientCheckTransaction struct {
	// contains filtered or unexported fields
}

func NewClientCheckTransaction

func NewClientCheckTransaction(walletStore WalletStore, interactor Interactor, nodeSelector node.Selector, pow SpamHandler) *ClientCheckTransaction

func (*ClientCheckTransaction) Handle

func (h *ClientCheckTransaction) Handle(ctx context.Context, rawParams jsonrpc.Params, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

type ClientCheckTransactionParams

type ClientCheckTransactionParams struct {
	PublicKey   string      `json:"publicKey"`
	Transaction interface{} `json:"transaction"`
}

type ClientCheckTransactionResult

type ClientCheckTransactionResult struct {
	ReceivedAt  time.Time               `json:"receivedAt"`
	SentAt      time.Time               `json:"sentAt"`
	Transaction *commandspb.Transaction `json:"transaction"`
}

type ClientConnectWallet

type ClientConnectWallet struct {
	// contains filtered or unexported fields
}

func NewConnectWallet

func NewConnectWallet(walletStore WalletStore, interactor Interactor) *ClientConnectWallet

func (*ClientConnectWallet) Handle

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 ClientGetChainID

type ClientGetChainID struct {
	// contains filtered or unexported fields
}

func NewGetChainID

func NewGetChainID(nodeSelector walletnode.Selector) *ClientGetChainID

func (*ClientGetChainID) Handle

type ClientGetChainIDResult

type ClientGetChainIDResult struct {
	ChainID string `json:"chainID"`
}

type ClientListKeys

type ClientListKeys struct {
	// contains filtered or unexported fields
}

func NewListKeys

func NewListKeys(walletStore WalletStore, interactor Interactor) *ClientListKeys

func (*ClientListKeys) Handle

func (h *ClientListKeys) Handle(ctx context.Context, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

Handle returns the public keys the third-party application has access to.

This requires a "read" access on "public_keys".

type ClientListKeysResult

type ClientListKeysResult struct {
	Keys []ClientNamedPublicKey `json:"keys"`
}

type ClientNamedPublicKey

type ClientNamedPublicKey struct {
	Name      string `json:"name"`
	PublicKey string `json:"publicKey"`
}

type ClientParsedCheckTransactionParams

type ClientParsedCheckTransactionParams struct {
	PublicKey      string
	RawTransaction string
}

type ClientParsedSendTransactionParams

type ClientParsedSendTransactionParams struct {
	PublicKey      string
	SendingMode    apipb.SubmitTransactionRequest_Type
	RawTransaction string
}

type ClientParsedSignTransactionParams

type ClientParsedSignTransactionParams struct {
	PublicKey      string
	RawTransaction string
}

type ClientSendTransaction

type ClientSendTransaction struct {
	// contains filtered or unexported fields
}

func NewClientSendTransaction

func NewClientSendTransaction(walletStore WalletStore, interactor Interactor, nodeSelector node.Selector, pow SpamHandler) *ClientSendTransaction

func (*ClientSendTransaction) Handle

func (h *ClientSendTransaction) Handle(ctx context.Context, rawParams jsonrpc.Params, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

type ClientSendTransactionParams

type ClientSendTransactionParams struct {
	PublicKey   string      `json:"publicKey"`
	SendingMode string      `json:"sendingMode"`
	Transaction interface{} `json:"transaction"`
}

type ClientSendTransactionResult

type ClientSendTransactionResult struct {
	ReceivedAt      time.Time               `json:"receivedAt"`
	SentAt          time.Time               `json:"sentAt"`
	TransactionHash string                  `json:"transactionHash"`
	Transaction     *commandspb.Transaction `json:"transaction"`
}

type ClientSignTransaction

type ClientSignTransaction struct {
	// contains filtered or unexported fields
}

func NewClientSignTransaction

func NewClientSignTransaction(walletStore WalletStore, interactor Interactor, nodeSelector node.Selector, proofOfWork SpamHandler) *ClientSignTransaction

func (*ClientSignTransaction) Handle

func (h *ClientSignTransaction) Handle(ctx context.Context, rawParams jsonrpc.Params, connectedWallet ConnectedWallet) (jsonrpc.Result, *jsonrpc.ErrorDetails)

type ClientSignTransactionParams

type ClientSignTransactionParams struct {
	PublicKey   string      `json:"publicKey"`
	Transaction interface{} `json:"transaction"`
}

type ClientSignTransactionResult

type ClientSignTransactionResult struct {
	Transaction *commandspb.Transaction `json:"transaction"`
}

type ConnectedWallet

type ConnectedWallet struct {
	// contains filtered or unexported fields
}

ConnectedWallet is the projection of the wallet through the permissions and authentication system. On a regular wallet, there are no restrictions on what we can call, which doesn't fit the model of having allowed access, so we wrap the "regular wallet" behind the "connected wallet".

func NewConnectedWallet

func NewConnectedWallet(hostname string, w wallet.Wallet) (ConnectedWallet, error)

func NewDisconnectedWallet

func NewDisconnectedWallet(hostname, wallet string) ConnectedWallet

func NewLongLivingConnectedWallet

func NewLongLivingConnectedWallet(w wallet.Wallet) ConnectedWallet

func (*ConnectedWallet) AllowedKeys

func (s *ConnectedWallet) AllowedKeys() []AllowedKey

AllowedKeys returns the keys a connection has access to. If a third-party application tries to use a keys that does not belong to this set, then the request should fail.

func (*ConnectedWallet) CanListKeys

func (s *ConnectedWallet) CanListKeys() bool

func (*ConnectedWallet) CanUseKey

func (s *ConnectedWallet) CanUseKey(publicKeyToUse string) bool

CanUseKey determines if the permissions allow the specified key to be used.

func (*ConnectedWallet) Hostname

func (s *ConnectedWallet) Hostname() string

Hostname returns the hostname for which the connection has been set. For long-living connections, the hostname is empty as there is no restrictions for that type of connection.

func (*ConnectedWallet) Name

func (s *ConnectedWallet) Name() string

func (*ConnectedWallet) RefreshFromWallet

func (s *ConnectedWallet) RefreshFromWallet(freshWallet wallet.Wallet) error

func (*ConnectedWallet) RequireInteraction

func (s *ConnectedWallet) RequireInteraction() bool

RequireInteraction tells if an interaction with the user is needed for supervision is required or not. It is related to the type of API token that is used for this connection. If it's a long-living token, then no interaction is required.

type Connection

type Connection struct {
	// Hostname is the hostname for which the connection is set.
	Hostname string `json:"hostname"`
	// Wallet is the wallet selected by the client for this connection.
	Wallet string `json:"wallet"`
}

type ConnectionsManager

type ConnectionsManager interface {
	EndSessionConnection(hostname, wallet string)
	ListSessionConnections() []Connection
}

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 (
	// InternalErrorType 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.
	InternalErrorType ErrorType = "Internal error"
	// ServerErrorType defines a programmatic error threw by the server, such as
	// a request cancellation. The server error targets error that happens in
	// the communication layer. It's different form application error.
	// It's a type of error that should be expected and handled.
	ServerErrorType ErrorType = "Server error"
	// NetworkErrorType defines an error that comes from the network and its nodes.
	NetworkErrorType ErrorType = "Network error"
	// ApplicationErrorType defines a programmatic error threw by the application
	// core, also called "business logic".
	ApplicationErrorType ErrorType = "Application error"
	// UserErrorType 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.
	UserErrorType ErrorType = "User error"
)

type Interactor

type Interactor interface {
	// NotifyInteractionSessionBegan notifies the beginning of an interaction
	// session.
	// A session is scoped to a request.
	NotifyInteractionSessionBegan(ctx context.Context, traceID string, workflow WorkflowType, numberOfSteps uint8) error

	// NotifyInteractionSessionEnded notifies the end of an interaction
	// session.
	// A session is scoped to a request.
	NotifyInteractionSessionEnded(ctx context.Context, traceID string)

	// NotifySuccessfulTransaction is used to report a successful transaction.
	NotifySuccessfulTransaction(ctx context.Context, traceID string, stepNumber uint8, txHash, deserializedInputData, tx string, sentAt time.Time, host string)

	// NotifyFailedTransaction is used to report a failed transaction.
	NotifyFailedTransaction(ctx context.Context, traceID string, stepNumber uint8, deserializedInputData, tx string, err error, sentAt time.Time, host string)

	// NotifySuccessfulRequest is used to notify the user the request is
	// successful.
	NotifySuccessfulRequest(ctx context.Context, traceID string, stepNumber uint8, message string)

	// NotifyError is used to report errors to the user.
	NotifyError(ctx context.Context, traceID string, t ErrorType, err error)

	// Log is used to report information of any kind to the user. This is used
	// to log internal activities and provide feedback to the wallet front-ends.
	// It's purely for informational purpose.
	// Receiving logs should be expected at any point during an interaction
	// session.
	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 the type of connection approval chosen by the user.
	RequestWalletConnectionReview(ctx context.Context, traceID string, stepNumber uint8, hostname string) (string, error)

	// RequestWalletSelection is used to trigger the selection of the wallet the
	// user wants to use for the specified hostname.
	RequestWalletSelection(ctx context.Context, traceID string, stepNumber uint8, hostname string, availableWallets []string) (string, error)

	// RequestPassphrase is used to request to the user the passphrase of a wallet.
	// It's primarily used by requests that update the wallet.
	RequestPassphrase(ctx context.Context, traceID string, stepNumber uint8, wallet, reason 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 string, stepNumber uint8, hostname, wallet string, perms map[string]string) (bool, error)

	// RequestTransactionReviewForSending 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.
	RequestTransactionReviewForSending(ctx context.Context, traceID string, stepNumber uint8, hostname, wallet, pubKey, transaction string, receivedAt time.Time) (bool, error)

	// RequestTransactionReviewForSigning 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.
	RequestTransactionReviewForSigning(ctx context.Context, traceID string, stepNumber uint8, hostname, wallet, pubKey, transaction string, receivedAt time.Time) (bool, error)

	// RequestTransactionReviewForChecking is used to prompt the user to check of the
	// transaction a third-party application wants to receive. The wallet doesn't
	// check the transaction.
	// It returns true if the user approved the transaction,
	// false otherwise.
	RequestTransactionReviewForChecking(ctx context.Context, traceID string, stepNumber uint8, hostname, wallet, pubKey, transaction string, receivedAt time.Time) (bool, error)
}

Interactor is the component in charge of delegating the JSON-RPC API requests, notifications and logs to the wallet front-end. Convention:

  • Notify* calls do not expect a response from the user.
  • Request* calls are expecting a response from the user.
  • Log function is just information logging and does not expect a response.

type LogType

type LogType string

LogType defines the type of log that is sent to the user.

var (
	InfoLog    LogType = "Info"
	WarningLog LogType = "Warning"
	ErrorLog   LogType = "Error"
	SuccessLog LogType = "Success"
)

type NetworkStore

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
	RenameNetwork(currentName, newName string) error
}

NetworkStore is the component used to retrieve and update the networks from the computer.

type NodeSelectorBuilder

type NodeSelectorBuilder func(hosts []string, retries uint64, ttl time.Duration) (node.Selector, error)

type ParsedAdminCheckTransactionParams

type ParsedAdminCheckTransactionParams struct {
	Wallet                 string
	PublicKey              string
	Network                string
	NodeAddress            string
	Retries                uint64
	RawTransaction         string
	MaximumRequestDuration time.Duration
}

type ParsedAdminSendRawTransactionParams

type ParsedAdminSendRawTransactionParams struct {
	Network                string
	NodeAddress            string
	Retries                uint64
	MaximumRequestDuration time.Duration
	SendingMode            apipb.SubmitTransactionRequest_Type
	RawTransaction         string
}

type ParsedAdminSendTransactionParams

type ParsedAdminSendTransactionParams struct {
	Wallet                 string
	PublicKey              string
	Network                string
	NodeAddress            string
	Retries                uint64
	SendingMode            apipb.SubmitTransactionRequest_Type
	RawTransaction         string
	MaximumRequestDuration time.Duration
}

type ParsedAdminSignTransactionParams

type ParsedAdminSignTransactionParams struct {
	Wallet                 string
	PublicKey              string
	RawTransaction         string
	Network                string
	Retries                uint64
	MaximumRequestDuration time.Duration
	LastBlockData          *AdminLastBlockData
}

type Reader

type Reader func(uri string, net interface{}) error

type Readers

type Readers struct {
	ReadFromFile Reader
	ReadFromURL  Reader
}

func NewReaders

func NewReaders() Readers

type SpamHandler

type SpamHandler interface {
	GenerateProofOfWork(pubKey string, blockData *nodetypes.SpamStatistics) (*commandspb.ProofOfWork, error)
	CheckSubmission(req *walletpb.SubmitTransactionRequest, latest *nodetypes.SpamStatistics) error
}

type WalletStore

type WalletStore interface {
	UnlockWallet(ctx context.Context, name, passphrase string) error
	LockWallet(ctx context.Context, name string) error
	WalletExists(ctx context.Context, name string) (bool, error)
	GetWallet(ctx context.Context, name string) (wallet.Wallet, error)
	ListWallets(ctx context.Context) ([]string, error)
	CreateWallet(ctx context.Context, w wallet.Wallet, passphrase string) error
	UpdateWallet(ctx context.Context, w wallet.Wallet) error
	UpdatePassphrase(ctx context.Context, name, newPassphrase string) error
	DeleteWallet(ctx context.Context, name string) error
	RenameWallet(ctx context.Context, currentName, newName string) error
	GetWalletPath(name string) string
	IsWalletAlreadyUnlocked(ctx context.Context, name string) (bool, error)
}

WalletStore is the component used to retrieve and update wallets from the computer.

type WorkflowType

type WorkflowType string

WorkflowType defines the type of interaction workflow that started by a method.

var (
	WalletConnectionWorkflow  WorkflowType = "WALLET_CONNECTION"
	TransactionReviewWorkflow WorkflowType = "TRANSACTION_REVIEW"
	PermissionRequestWorkflow WorkflowType = "PERMISSION_REQUEST"
	WalletUnlockingWorkflow   WorkflowType = "WALLET_UNLOCKING"
)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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