Documentation
¶
Overview ¶
Package config provides a configuration for the API
Index ¶
- Constants
- type AppConfig
- func (config *AppConfig) BlockHeaderServiceEnabled() bool
- func (config *AppConfig) CheckBlockHeaderService(ctx context.Context, logger *zerolog.Logger)
- func (a *AppConfig) GetUserAgent() string
- func (a *AppConfig) LoadServices(ctx context.Context) (*AppServices, error)
- func (a *AppConfig) LoadTestServices(ctx context.Context) (*AppServices, error)
- func (a *AppConfig) Validate() error
- type AppServices
- type AuthenticationConfig
- type BeefConfig
- type CacheConfig
- type CallbackConfig
- type ClusterConfig
- type DatastoreConfig
- type DbConfig
- type ExperimentalConfig
- type FeeUnitConfig
- type LoggingConfig
- type MetricsConfig
- type MinerAPI
- type NewRelicConfig
- type NodesConfig
- type NodesProtocol
- type NotificationsConfig
- type PaymailConfig
- type RedisConfig
- type ServerConfig
- type TaskManagerConfig
Constants ¶
const ( ApplicationName = "SPVWallet" APIVersion = "v1" DefaultNewRelicShutdown = 10 * time.Second HealthRequestPath = "health" Version = "v0.12.0" ConfigFilePathKey = "config_file" DefaultConfigFilePath = "config.yaml" EnvPrefix = "SPVWALLET" BroadcastCallbackRoute = "/transaction/broadcast/callback" )
Config constants used for spv-wallet
const (
// AuthenticationSchemeXpub is the xpub auth scheme (using xPubs as tokens)
AuthenticationSchemeXpub = "xpub"
)
const DefaultAdminXpub = "xpub661MyMwAqRbcFgfmdkPgE2m5UjHXu9dj124DbaGLSjaqVESTWfCD4VuNmEbVPkbYLCkykwVZvmA8Pbf8884TQr1FgdG2nPoHR8aB36YdDQh"
DefaultAdminXpub is the default admin xpub used for authenticate requests.
const (
TaskManagerQueueName = "spv_wallet_queue"
)
TaskManager defaults
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct { // Authentication is the configuration for keys authentication in SPV Wallet. Authentication *AuthenticationConfig `json:"auth" mapstructure:"auth"` // Cache is the configuration for cache, memory or redis, and cluster cache settings. Cache *CacheConfig `json:"cache" mapstructure:"cache"` // Db is the configuration for database related settings. Db *DbConfig `json:"db" mapstructure:"db"` // Debug is a flag for enabling additional information from SPV Wallet. Debug bool `json:"debug" mapstructure:"debug"` // DebugProfiling is a flag for enabling additinal debug profiling. DebugProfiling bool `json:"debug_profiling" mapstructure:"debug_profiling"` // DisableITC is a flag for disabling Incoming Transaction Checking. DisableITC bool `json:"disable_itc" mapstructure:"disable_itc"` // ImportBlockHeaders is a URL from where the headers can be downloaded. ImportBlockHeaders string `json:"import_block_headers" mapstructure:"import_block_headers"` // Logging is the configuration for zerolog used in SPV Wallet. Logging *LoggingConfig `json:"logging" mapstructure:"logging"` // NewRelic is New Relic related settings. NewRelic *NewRelicConfig `json:"new_relic" mapstructure:"new_relic"` // Nodes is a config for BSV nodes, mAPI and Arc. Nodes *NodesConfig `json:"nodes" mapstructure:"nodes"` // Notifications is a config for Notification service. Notifications *NotificationsConfig `json:"notifications" mapstructure:"notifications"` // Paymail is a config for Paymail and BEEF. Paymail *PaymailConfig `json:"paymail" mapstructure:"paymail"` // RequestLogging is flag for enabling logging in go-api-router. RequestLogging bool `json:"request_logging" mapstructure:"request_logging"` // Server is a general configuration for spv-wallet. Server *ServerConfig `json:"server_config" mapstructure:"server_config"` // TaskManager is a configuration for Task Manager in SPV Wallet. TaskManager *TaskManagerConfig `json:"task_manager" mapstructure:"task_manager"` // Metrics is a configuration for metrics in SPV Wallet. Metrics *MetricsConfig `json:"metrics" mapstructure:"metrics"` // ExperimentalFeatures is a configuration that allows to enable features that are considered experimental/non-production. ExperimentalFeatures *ExperimentalConfig `json:"experimental_features" mapstructure:"experimental_features"` }
AppConfig is the configuration values and associated env vars
func LoadForTest ¶ added in v0.21.0
func LoadForTest() (appConfig *AppConfig)
LoadForTest returns test AppConfig
func (*AppConfig) BlockHeaderServiceEnabled ¶
BlockHeaderServiceEnabled returns true if the Block Headers Service is enabled in the AppConfig
func (*AppConfig) CheckBlockHeaderService ¶
CheckBlockHeaderService tries to make a request to the Block Headers Service to check if it is online and ready to verify transactions. AppConfig should be validated before calling this method. This method returns nothing, instead it logs either an error or a warning based on the state of the Block Headers Service.
func (*AppConfig) GetUserAgent ¶
GetUserAgent will return the outgoing user agent
func (*AppConfig) LoadServices ¶
func (a *AppConfig) LoadServices(ctx context.Context) (*AppServices, error)
LoadServices will load and return new set of services, updating the AppConfig
func (*AppConfig) LoadTestServices ¶
func (a *AppConfig) LoadTestServices(ctx context.Context) (*AppServices, error)
LoadTestServices will load the "minimum" for testing
type AppServices ¶
type AppServices struct { SpvWalletEngine engine.ClientInterface NewRelic *newrelic.Application Logger *zerolog.Logger }
AppServices is the loaded services via config
func (*AppServices) CloseAll ¶
func (s *AppServices) CloseAll(ctx context.Context)
CloseAll will close all connections to all services
type AuthenticationConfig ¶
type AuthenticationConfig struct { // AdminKey is used for administrative requests AdminKey string `json:"admin_key" mapstructure:"admin_key"` // RequireSigning is the flag that decides if the signing is required RequireSigning bool `json:"require_signing" mapstructure:"require_signing"` // Scheme it the authentication scheme to use (default is: xpub) Scheme string `json:"scheme" mapstructure:"scheme"` // SigningDisabled turns off signing. NOTE: Only for development SigningDisabled bool `json:"signing_disabled" mapstructure:"signing_disabled"` }
AuthenticationConfig is the configuration for Authentication
func (*AuthenticationConfig) IsAdmin ¶
func (a *AuthenticationConfig) IsAdmin(key string) bool
IsAdmin will check if the key is an admin key
func (*AuthenticationConfig) Validate ¶
func (a *AuthenticationConfig) Validate() error
Validate checks the configuration for specific rules
type BeefConfig ¶
type BeefConfig struct { // UseBeef is a flag for enabling BEEF transactions format. UseBeef bool `json:"use_beef" mapstructure:"use_beef"` // BlockHeaderServiceHeaderValidationURL is the URL for merkle roots validation in Block Headers Service. BlockHeaderServiceHeaderValidationURL string `json:"block_header_service_url" mapstructure:"block_header_service_url"` // BlockHeaderServiceAuthToken is the authentication token for validating merkle roots in Block Headers Service. BlockHeaderServiceAuthToken string `json:"block_header_service_auth_token" mapstructure:"block_header_service_auth_token"` }
BeefConfig consists of components required to use beef, e.g. Block Headers Service for merkle roots validation
type CacheConfig ¶
type CacheConfig struct { // Engine is the cache engine to use (redis, freecache). Engine cachestore.Engine `json:"engine" mapstructure:"engine"` // Cluster is the cluster-specific configuration for SPV Wallet. Cluster *ClusterConfig `json:"cluster" mapstructure:"cluster"` // Redis is a general config for redis if the engine is set to it. Redis *RedisConfig `json:"redis" mapstructure:"redis"` }
CacheConfig is a configuration for cachestore
func (*CacheConfig) Validate ¶
func (c *CacheConfig) Validate() error
Validate checks the configuration for specific rules
type CallbackConfig ¶
type CallbackConfig struct { // CallbackHost is the URL for broadcast callback registration. CallbackHost string `json:"callback_host" mapstructure:"callback_host"` // CallbackToken is the token for broadcast callback registration. CallbackToken string `json:"callback_token" mapstructure:"callback_token"` }
CallbackConfig is the configuration for callbacks
type ClusterConfig ¶
type ClusterConfig struct { // Coordinator is a cluster coordinator (redis or memory). Coordinator cluster.Coordinator `json:"coordinator" mapstructure:"coordinator"` // Prefix is the string to use for all cluster keys. Prefix string `json:"prefix" mapstructure:"prefix"` // Redis is cluster-specific redis config, will use cache config if this is unset. Redis *RedisConfig `json:"redis" mapstrcuture:"redis"` }
ClusterConfig is a configuration for the SPV Wallet cluster
type DatastoreConfig ¶
type DatastoreConfig struct { // Debug is a flag that decides whether additional output (such as sql statements) should be produced from datastore. Debug bool `json:"debug" mapstructure:"debug"` // Engine is the database to be used, mysql, sqlite, postgresql. Engine datastore.Engine `json:"engine" mapstructure:"engine"` // TablePrefix is the prefix for all table names in the database. TablePrefix string `json:"table_prefix" mapstructure:"table_prefix"` }
DatastoreConfig is a configuration for the datastore
type DbConfig ¶
type DbConfig struct { // Datastore general config. Datastore *DatastoreConfig `json:"datastore" mapstructure:"datastore"` // Mongo is a config for MongoDb. Works only if datastore engine is set to mongodb. Mongo *datastore.MongoDBConfig `json:"mongodb" mapstructure:"mongodb"` // SQL is a config for PostgreSQL or MySQL. Works only if datastore engine is set to postgresql or mysql. SQL *datastore.SQLConfig `json:"sql" mapstructure:"sql"` // SQLite is a config for SQLite. Works only if datastore engine is set to sqlite. SQLite *datastore.SQLiteConfig `json:"sqlite" mapstructure:"sqlite"` }
DbConfig consists of datastore config and specific dbs configs
type ExperimentalConfig ¶ added in v0.19.0
type ExperimentalConfig struct {
PikeEnabled bool `json:"pike_enabled" mapstructure:"pike_enabled"`
}
ExperimentalConfig represents a feature flag config.
type FeeUnitConfig ¶
type FeeUnitConfig struct { Satoshis int `json:"satoshis" mapstructure:"satoshis"` Bytes int `json:"bytes" mapstructure:"bytes"` }
FeeUnitConfig reflects the utils.FeeUnit struct with proper annotations for json and mapstructure
type LoggingConfig ¶
type LoggingConfig struct { // Level is the importance and amount of information printed: debug, info, warn, error, fatal, panic, etc. Level string `json:"level" mapstructure:"level"` // Format is the format of logs, json (for gathering eg. into elastic) or console (for stdout). Format string `json:"format" mapstructure:"format"` // InstanceName is the name of the zerolog instance. InstanceName string `json:"instance_name" mapstructure:"instance_name"` // LogOrigin is the flag for whether the origin of logs should be printed. LogOrigin bool `json:"log_origin" mapstructure:"log_origin"` }
LoggingConfig is a configuration for logging
type MetricsConfig ¶
type MetricsConfig struct { // Enabled is a flag for enabling metrics. Enabled bool `json:"enabled" mapstructure:"enabled"` }
MetricsConfig represents a metrics config.
type MinerAPI ¶
type MinerAPI struct { Token string `json:"token" mapstructure:"token"` ArcURL string `json:"arc_url" mapstructure:"arc_url"` MapiURL string `json:"mapi_url" mapstructure:"mapi_url"` // MinerID is not used with ARC potocol MinerID string `json:"minerid" mapstructure:"minerid"` }
MinerAPI holds connection info for a single miner endpoint
type NewRelicConfig ¶
type NewRelicConfig struct { // DomainName is used for hostname display. DomainName string `json:"domain_name" mapstructure:"domain_name"` // Enabled is the flag that enables New Relic service. Enabled bool `json:"enabled" mapstructure:"enabled"` // LicenseKey is the New Relic license key. LicenseKey string `json:"license_key" mapstructure:"license_key"` }
NewRelicConfig is the configuration for New Relic
func (*NewRelicConfig) Validate ¶
func (n *NewRelicConfig) Validate() error
Validate checks the configuration for specific rules
type NodesConfig ¶
type NodesConfig struct { DeploymentID string `json:"deployment_id" mapstructure:"deployment_id"` Callback *CallbackConfig `json:"callback" mapstructure:"callback"` Protocol NodesProtocol `json:"protocol" mapstructure:"protocol"` Apis []*MinerAPI `json:"apis" mapstructure:"apis"` UseFeeQuotes bool `json:"use_fee_quotes" mapstructure:"use_fee_quotes"` FeeUnit *FeeUnitConfig `json:"fee_unit" mapstructure:"fee_unit"` }
NodesConfig consists of blockchain nodes (such as Minercraft and Arc) configuration
func (*NodesConfig) Validate ¶
func (n *NodesConfig) Validate() error
Validate checks the configuration for specific rules
type NodesProtocol ¶
type NodesProtocol string
NodesProtocol is the protocol/api_type used to communicate with the miners
const ( // NodesProtocolMapi represents the mapi protocol provided by minercraft NodesProtocolMapi NodesProtocol = "mapi" // NodesProtocolArc represents the arc protocol provided by go-broadcast-client NodesProtocolArc NodesProtocol = "arc" )
func (NodesProtocol) Validate ¶
func (n NodesProtocol) Validate() error
Validate whether the protocol is known
type NotificationsConfig ¶
type NotificationsConfig struct { // Enabled is the flag that enables notifications service. Enabled bool `json:"enabled" mapstructure:"enabled"` // WebhookEndpoint is the endpoint for webhook registration. WebhookEndpoint string `json:"webhook_endpoint" mapstructure:"webhook_endpoint"` }
NotificationsConfig is the configuration for notifications
type PaymailConfig ¶
type PaymailConfig struct { // Beef is for Background Evaluation Extended Format (BEEF) config. Beef *BeefConfig `json:"beef" mapstructure:"beef"` // DefaultFromPaymail IE: from@domain.com. DefaultFromPaymail string `json:"default_from_paymail" mapstructure:"default_from_paymail"` // Domains is a list of allowed domains. Domains []string `json:"domains" mapstructure:"domains"` // DomainValidationEnabled should be turned off if hosted domain is not paymail related. DomainValidationEnabled bool `json:"domain_validation_enabled" mapstructure:"domain_validation_enabled"` // SenderValidationEnabled should be turned on for extra security. SenderValidationEnabled bool `json:"sender_validation_enabled" mapstructure:"sender_validation_enabled"` }
PaymailConfig is the configuration for the built-in Paymail server
func (*PaymailConfig) Validate ¶
func (p *PaymailConfig) Validate() error
Validate checks the configuration for specific rules
type RedisConfig ¶
type RedisConfig struct { // DependencyMode works only in Redis with script enabled. DependencyMode bool `json:"dependency_mode" mapstructure:"dependency_mode"` // MaxActiveConnections is maximum number of active redis connections. MaxActiveConnections int `json:"max_active_connections" mapstructure:"max_active_connections"` // MaxConnectionLifetime is the maximum duration of the connection. MaxConnectionLifetime time.Duration `json:"max_connection_lifetime" mapstructure:"max_connection_lifetime"` // MaxIdleConnections is the maximum number of idle connections. MaxIdleConnections int `json:"max_idle_connections" mapstructure:"max_idle_connections"` // MaxIdleTimeout is the maximum duration of idle redis connection before timeout. MaxIdleTimeout time.Duration `json:"max_idle_timeout" mapstructure:"max_idle_timeout"` // URL is Redis url connection string. URL string `json:"url" mapstructure:"url"` // UseTLS is a flag which decides whether to use TLS UseTLS bool `json:"use_tls" mapstructure:"use_tls"` }
RedisConfig is a configuration for Redis cachestore or taskmanager
type ServerConfig ¶
type ServerConfig struct { // IdleTimeout is the maximum duration before server timeout. IdleTimeout time.Duration `json:"idle_timeout" mapstructure:"idle_timeout"` // ReadTimeout is the maximum duration for server read timeout. ReadTimeout time.Duration `json:"read_timeout" mapstructure:"read_timeout"` // WriteTimeout is the maximum duration for server write timeout. WriteTimeout time.Duration `json:"write_timeout" mapstructure:"write_timeout"` // Port is the port that the server should use. Port int `json:"port" mapstructure:"port"` }
ServerConfig is a configuration for the HTTP Server
func (*ServerConfig) Validate ¶
func (s *ServerConfig) Validate() error
Validate checks the configuration for specific rules
type TaskManagerConfig ¶
type TaskManagerConfig struct { // Factory is the Task Manager factory, memory or redis. Factory taskmanager.Factory `json:"factory" mapstructure:"factory"` }
TaskManagerConfig is a configuration for the taskmanager