config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BitcoinConfigFileName  = "bitcoin.toml"
	AppConfigFileName      = "indexer.toml"
	HTTPConfigFileName     = "http.toml"
	BitcoinConfigEnvPrefix = "BITCOIN"
	AppConfigEnvPrefix     = "APP"
	HTTPConfigEnvPrefix    = "HTTP"
)

Variables

View Source
var DefaultDepositAbi = `` /* 8970-byte string literal not displayed */

Functions

func ChainParams

func ChainParams(network string) *chaincfg.Params

ChainParams get chain params by network name

Types

type BitcoinConfig

type BitcoinConfig struct {
	// NetworkName defines the bitcoin network name
	NetworkName string `mapstructure:"network-name" env:"BITCOIN_NETWORK_NAME"`
	// RPCHost defines the bitcoin rpc host
	RPCHost string `mapstructure:"rpc-host" env:"BITCOIN_RPC_HOST"`
	// RPCPort defines the bitcoin rpc port
	RPCPort string `mapstructure:"rpc-port" env:"BITCOIN_RPC_PORT"`
	// RPCUser defines the bitcoin rpc user
	RPCUser string `mapstructure:"rpc-user" env:"BITCOIN_RPC_USER"`
	// RPCPass defines the bitcoin rpc password
	RPCPass string `mapstructure:"rpc-pass" env:"BITCOIN_RPC_PASS"`
	// DisableTLS defines the bitcoin whether tls is required
	DisableTLS bool `mapstructure:"disable-tls" env:"BITCOIN_DISABLE_TLS" envDefault:"true"`
	// WalletName defines the bitcoin wallet name
	WalletName string `mapstructure:"wallet-name" env:"BITCOIN_WALLET_NAME"`
	// EnableIndexer defines whether to enable the indexer
	EnableIndexer bool `mapstructure:"enable-indexer" env:"BITCOIN_ENABLE_INDEXER"`
	// IndexerListenAddress defines the address to listen on
	IndexerListenAddress string `mapstructure:"indexer-listen-address" env:"BITCOIN_INDEXER_LISTEN_ADDRESS"`
	// IndexerListenTargetConfirmations defines the number of confirmations to listen on
	IndexerListenTargetConfirmations uint64 `mapstructure:"indexer-listen-target-confirmations" env:"BITCOIN_INDEXER_LISTEN_TARGET_CONFIRMATIONS" envDefault:"1"`
	// Bridge defines the bridge config
	Bridge BridgeConfig `mapstructure:"bridge"`
	Eps    EpsConfig    `mapstructure:"eps"`
}

BitcoinConfig defines the bitcoin config

func DefaultBitcoinConfig

func DefaultBitcoinConfig() *BitcoinConfig

func LoadBitcoinConfig

func LoadBitcoinConfig(homePath string) (*BitcoinConfig, error)

type BridgeConfig

type BridgeConfig struct {
	// EthRPCURL defines the ethereum rpc url, b2 rollup rpc
	EthRPCURL string `mapstructure:"eth-rpc-url" env:"BITCOIN_BRIDGE_ETH_RPC_URL"`
	// EthPrivKey defines the invoke ethereum private key
	EthPrivKey string `mapstructure:"eth-priv-key" env:"BITCOIN_BRIDGE_ETH_PRIV_KEY"`
	// ContractAddress defines the l1 -> l2 bridge contract address
	ContractAddress string `mapstructure:"contract-address" env:"BITCOIN_BRIDGE_CONTRACT_ADDRESS"`
	// ABI defines the l1 -> l2 bridge contract abi
	ABI string `mapstructure:"abi" env:"BITCOIN_BRIDGE_ABI"`
	// if deposit invoke b2 failed(status != 1), Whether to allow invoke eoa trnasfer
	EnableEoaTransfer bool `mapstructure:"enable-eoa-transfer" env:"BITCOIN_BRIDGE_ENABLE_EOA_TRANSFER" envDefault:"true"`
	// AAB2PI get pubkey by btc address
	AAB2PI string `mapstructure:"aa-b2-api" env:"BITCOIN_BRIDGE_AA_B2_API"`
	// AAParticleRPC defines the particle api
	AAParticleRPC string `mapstructure:"aa-particle-rpc" env:"BITCOIN_BRIDGE_AA_PARTICLE_RPC"`
	// AAParticleProjectID defines the particle project id
	AAParticleProjectID string `mapstructure:"aa-particle-project-id" env:"BITCOIN_BRIDGE_AA_PARTICLE_PROJECT_ID"`
	// AAParticleServerKey defines the particle server key
	AAParticleServerKey string `mapstructure:"aa-particle-server-key" env:"BITCOIN_BRIDGE_AA_PARTICLE_SERVER_KEY"`
	// AAParticleChainID defines the particle chain id
	AAParticleChainID int `mapstructure:"aa-particle-chain-id" env:"BITCOIN_BRIDGE_AA_PARTICLE_CHAIN_ID"`
	// GasPriceMultiple defines the gas price multiple, TODO: temp fix, base gas_price * n
	GasPriceMultiple int64 `mapstructure:"gas-price-multiple" env:"BITCOIN_BRIDGE_GAS_PRICE_MULTIPLE" envDefault:"2"`
	// B2ExplorerURL defines the b2 explorer url, TODO: temp use explorer gas prices
	B2ExplorerURL string `mapstructure:"b2-explorer-url" env:"BITCOIN_BRIDGE_B2_EXPLORER_URL"`
	// EnableListener defines whether to enable the listener
	EnableWithdrawListener bool `mapstructure:"enable-withdraw-listener" env:"BITCOIN_BRIDGE_WITHDRAW_ENABLE_LISTENER"`
	// Deposit defines the deposit event hash
	Deposit string `mapstructure:"deposit" env:"BITCOIN_BRIDGE_DEPOSIT"`
	// Withdraw defines the withdraw event hash
	Withdraw string `mapstructure:"withdraw" env:"BITCOIN_BRIDGE_WITHDRAW"`
	// UnisatApiKey defines unisat api_key
	UnisatAPIKey string `mapstructure:"unisat-api-key" env:"BITCOIN_BRIDGE_UNISAT_API_KEY"`
	// PublicKeys defines signer publickey
	PublicKeys []string `mapstructure:"publickeys" env:"BITCOIN_BRIDGE_PUBLICKEYS"`
	// TimeInterval defines withdraw time interval
	TimeInterval int64 `mapstructure:"time-interval" env:"BITCOIN_BRIDGE_TIME_INTERVAL"`
	// MultisigNum defines withdraw multisig number
	MultisigNum int `mapstructure:"multisig-num" env:"BITCOIN_BRIDGE_MULTISIG_NUM"`
	// EnableRollupListener defines rollup index server
	EnableRollupListener bool `mapstructure:"enable-rollup-listener" env:"BITCOIN_BRIDGE_ROLLUP_ENABLE_LISTENER"`
	// EnableVSM defines whether to enable the vsm encryption/decryption
	EnableVSM bool `mapstructure:"enable-vsm" env:"BITCOIN_BRIDGE_ENABLE_VSM"`
	// VSMInternalKeyIndex defines the vsm internal key index
	VSMInternalKeyIndex uint `mapstructure:"vsm-internal-key-index" env:"BITCOIN_BRIDGE_VSM_INTERNAL_KEY_INDEX"`
	// VSMIv defines the vsm iv
	VSMIv string `mapstructure:"vsm-iv" env:"BITCOIN_BRIDGE_VSM_IV"`
	// LocalDecryptKey defines the bridge server local enc key
	LocalDecryptKey string `mapstructure:"local-decrypt-key" env:"BITCOIN_BRIDGE_LOCAL_DECRYPT_KEY"`
	// LocalAesAlg defines the bridge server local dec alg, rsa aes
	LocalDecryptAlg string `mapstructure:"local-decrypt-alg" env:"BITCOIN_BRIDGE_LOCAL_DECRYPT_ALG"`
}

type Config

type Config struct {
	// The root directory for all data.
	// This should be set in viper so it can unmarshal into this struct
	RootDir  string `mapstructure:"root-dir" env:"INDEXER_ROOT_DIR"`
	LogLevel string `mapstructure:"log-level" env:"INDEXER_LOG_LEVEL" envDefault:"info"`
	// "console","json"
	LogFormat               string `mapstructure:"log-format" env:"INDEXER_LOG_FORMAT" envDefault:"console"`
	DatabaseSource          string `` /* 128-byte string literal not displayed */
	DatabaseMaxIdleConns    int    `mapstructure:"database-max-idle-conns"  env:"INDEXER_DATABASE_MAX_IDLE_CONNS" envDefault:"10"`
	DatabaseMaxOpenConns    int    `mapstructure:"database-max-open-conns" env:"INDEXER_DATABASE_MAX_OPEN_CONNS" envDefault:"20"`
	DatabaseConnMaxLifetime int    `mapstructure:"database-conn-max-lifetime" env:"INDEXER_DATABASE_CONN_MAX_LIFETIME" envDefault:"3600"`
}

Config is the global config.

func DefaultConfig

func DefaultConfig() *Config

func LoadConfig

func LoadConfig(homePath string) (*Config, error)

type EpsConfig

type EpsConfig struct {
	EnableEps     bool   `mapstructure:"enable-eps" env:"ENABLE_EPS"`
	URL           string `mapstructure:"url" env:"EPS_URL"`
	Authorization string `mapstructure:"authorization" env:"EPS_AUTHORIZATION"`
}

TODO: @robertcc0410 env prefix, mapstructure and env, env prefix in the rule must be the same

type HTTPConfig

type HTTPConfig struct {
	// port defines the http server port
	HTTPPort string `mapstructure:"http-port" env:"HTTP_PORT" envDefault:"9090"`
	// port defines the grpc server port
	GrpcPort string `mapstructure:"grpc-port" env:"HTTP_GRPC_PORT" envDefault:"9091"`
	// ipWhiteList defines the ip white list, Only those in the whitelist can be called
	IPWhiteList string `mapstructure:"ip-white-list" env:"HTTP_IP_WHITE_LIST"`
}

HTTPConfig defines the http server config

func LoadHTTPConfig

func LoadHTTPConfig(homePath string) (*HTTPConfig, error)

Jump to

Keyboard shortcuts

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