diff --git a/actions/admin/models.go b/actions/admin/models.go index 51c1c312d..81b511ab7 100644 --- a/actions/admin/models.go +++ b/actions/admin/models.go @@ -6,6 +6,8 @@ import ( // CreatePaymail is the model for creating a paymail type CreatePaymail struct { + // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource + Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` // The xpub with which the paymail is associated Key string `json:"key" example:"xpub661MyMwAqRbcGpZVrSHU..."` // The paymail address @@ -14,8 +16,6 @@ type CreatePaymail struct { PublicName string `json:"public_name" example:"Test"` // The avatar of the paymail (url address) Avatar string `json:"avatar" example:"https://example.com/avatar.png"` - // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource - Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` } // PaymailAddress is the model containing only paymail address used for getting and deleting paymail address @@ -32,8 +32,8 @@ type RecordTransaction struct { // CreateXpub is the model for creating an xpub type CreateXpub struct { - // The xpub key - Key string `json:"key" example:"xpub661MyMwAqRbcGpZVrSHU..."` // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` + // The xpub key + Key string `json:"key" example:"xpub661MyMwAqRbcGpZVrSHU..."` } diff --git a/actions/destinations/models.go b/actions/destinations/models.go index c45784b5a..0789dd1b4 100644 --- a/actions/destinations/models.go +++ b/actions/destinations/models.go @@ -12,12 +12,12 @@ type CreateDestination struct { // UpdateDestination is the model for updating a destination type UpdateDestination struct { + // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource + Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` // ID of the destination which is the hash of the LockingScript ID string `json:"id" example:"82a5d848f997819a478b05fb713208d7f3aa66da5ba00953b9845fb1701f9b98"` // Address of the destination Address string `json:"address" example:"1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65"` // LockingScript of the destination LockingScript string `json:"locking_script" example:"76a9147b05764a97f3b4b981471492aa703b188e45979b88ac"` - // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource - Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` } diff --git a/actions/transactions/models.go b/actions/transactions/models.go index ef66e0d50..ac4171c1e 100644 --- a/actions/transactions/models.go +++ b/actions/transactions/models.go @@ -7,20 +7,20 @@ import ( // UpdateTransaction is the model for updating a transaction type UpdateTransaction struct { - // Id of the transaction which is a hash of the transaction - ID string `json:"id" example:"01d0d0067652f684c6acb3683763f353fce55f6496521c7d99e71e1d27e53f5c"` // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` + // ID of the transaction which is a hash of the transaction + ID string `json:"id" example:"01d0d0067652f684c6acb3683763f353fce55f6496521c7d99e71e1d27e53f5c"` } // RecordTransaction is the model for recording a transaction type RecordTransaction struct { + // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource + Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` // Hex of the transaction Hex string `json:"hex" example:"0100000002..."` // ReferenceID which is a ID of the draft transaction ReferenceID string `json:"reference_id" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"` - // Accepts a JSON object for embedding custom metadata, enabling arbitrary additional information to be associated with the resource - Metadata engine.Metadata `json:"metadata" swaggertype:"object,string" example:"key:value,key2:value2"` } // NewTransaction is the model for creating a new transaction diff --git a/config/config.go b/config/config.go index 540b48d82..fdbd73a4c 100644 --- a/config/config.go +++ b/config/config.go @@ -31,14 +31,14 @@ type AppConfig struct { 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"` + // 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"` // Logging is the configuration for zerolog used in SPV Wallet. Logging *LoggingConfig `json:"logging" mapstructure:"logging"` // NewRelic is New Relic related settings. @@ -49,38 +49,38 @@ type AppConfig struct { Notifications *NotificationsConfig `json:"notifications" mapstructure:"notifications"` // Paymail is a config for Paymail and BEEF. Paymail *PaymailConfig `json:"paymail" mapstructure:"paymail"` + // 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"` // 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"` + // ImportBlockHeaders is a URL from where the headers can be downloaded. + ImportBlockHeaders string `json:"import_block_headers" mapstructure:"import_block_headers"` } // AuthenticationConfig is the configuration for Authentication 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"` + // AdminKey is used for administrative requests + AdminKey string `json:"admin_key" mapstructure:"admin_key"` + // Scheme it the authentication scheme to use (default is: xpub) + Scheme string `json:"scheme" mapstructure:"scheme"` } // CacheConfig is a configuration for cachestore 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"` + // Engine is the cache engine to use (redis, freecache). + Engine cachestore.Engine `json:"engine" mapstructure:"engine"` } // CallbackConfig is the configuration for callbacks @@ -93,30 +93,30 @@ type CallbackConfig struct { // ClusterConfig is a configuration for the SPV Wallet cluster type ClusterConfig struct { + // Redis is cluster-specific redis config, will use cache config if this is unset. + Redis *RedisConfig `json:"redis" mapstrcuture:"redis"` // 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"` } // RedisConfig is a configuration for Redis cachestore or taskmanager type RedisConfig struct { // DependencyMode works only in Redis with script enabled. DependencyMode bool `json:"dependency_mode" mapstructure:"dependency_mode"` + // UseTLS is a flag which decides whether to use TLS + UseTLS bool `json:"use_tls" mapstructure:"use_tls"` // 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"` + // MaxConnectionLifetime is the maximum duration of the connection. + MaxConnectionLifetime time.Duration `json:"max_connection_lifetime" mapstructure:"max_connection_lifetime"` // 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"` } // DbConfig consists of datastore config and specific dbs configs @@ -135,30 +135,30 @@ type DbConfig struct { 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"` + // Engine is the database to be used, mysql, sqlite, postgresql. + Engine datastore.Engine `json:"engine" mapstructure:"engine"` } // NewRelicConfig is the configuration for New Relic 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"` + // DomainName is used for hostname display. + DomainName string `json:"domain_name" mapstructure:"domain_name"` // LicenseKey is the New Relic license key. LicenseKey string `json:"license_key" mapstructure:"license_key"` } // NodesConfig consists of blockchain nodes (such as Minercraft and Arc) configuration 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"` + UseFeeQuotes bool `json:"use_fee_quotes" mapstructure:"use_fee_quotes"` + DeploymentID string `json:"deployment_id" mapstructure:"deployment_id"` + Protocol NodesProtocol `json:"protocol" mapstructure:"protocol"` } // FeeUnitConfig reflects the utils.FeeUnit struct with proper annotations for json and mapstructure @@ -179,10 +179,10 @@ type MinerAPI struct { // NotificationsConfig is the configuration for notifications 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"` + // Enabled is the flag that enables notifications service. + Enabled bool `json:"enabled" mapstructure:"enabled"` } // LoggingConfig is a configuration for logging @@ -213,12 +213,12 @@ type PaymailConfig struct { // BeefConfig consists of components required to use beef, e.g. Block Headers Service for merkle roots validation 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"` + // UseBeef is a flag for enabling BEEF transactions format. + UseBeef bool `json:"use_beef" mapstructure:"use_beef"` } func (b *BeefConfig) enabled() bool { diff --git a/dictionary/dictionary.go b/dictionary/dictionary.go index 92805051d..69a11f8a4 100644 --- a/dictionary/dictionary.go +++ b/dictionary/dictionary.go @@ -9,9 +9,9 @@ import ( // ErrorMessage is used for standardizing the messages/codes for errors type ErrorMessage struct { Code ErrorCode `json:"code"` + StatusCode int `json:"status_code"` InternalMessage string `json:"internal_message"` PublicMessage string `json:"public_message"` - StatusCode int `json:"status_code"` } // errorMessages is the public diff --git a/dictionary/dictionary_test.go b/dictionary/dictionary_test.go index 37de6e64e..57e2cde8f 100644 --- a/dictionary/dictionary_test.go +++ b/dictionary/dictionary_test.go @@ -12,59 +12,59 @@ func TestErrorCode_IsValid(t *testing.T) { t.Parallel() var tests = []struct { - testCase string - code ErrorCode expectValid bool + code ErrorCode + testCase string }{ { - "ErrorBadErrorCode", - ErrorBadErrorCode, true, + ErrorBadErrorCode, + "ErrorBadErrorCode", }, { - "ErrorMissingEnv", - ErrorMissingEnv, true, + ErrorMissingEnv, + "ErrorMissingEnv", }, { - "ErrorInvalidEnv", - ErrorInvalidEnv, true, + ErrorInvalidEnv, + "ErrorInvalidEnv", }, { - "ErrorReadingConfig", - ErrorReadingConfig, true, + ErrorReadingConfig, + "ErrorReadingConfig", }, { - "ErrorViper", - ErrorViper, true, + ErrorViper, + "ErrorViper", }, { - "ErrorConfigValidation", - ErrorConfigValidation, true, + ErrorConfigValidation, + "ErrorConfigValidation", }, { - "ErrorDecryptEnv", - ErrorDecryptEnv, true, + ErrorDecryptEnv, + "ErrorDecryptEnv", }, { - "ErrorLoadingConfig", - ErrorLoadingConfig, true, + ErrorLoadingConfig, + "ErrorLoadingConfig", }, { - "ErrorLoadingCache", - ErrorLoadingCache, true, + ErrorLoadingCache, + "ErrorLoadingCache", }, { - "unknown code", - 9999, false, + 9999, + "unknown code", }, }