models.go raw

   1  package config
   2  
   3  const (
   4  	LNDBackendType     = "LND"
   5  	LDKBackendType     = "LDK"
   6  	PhoenixBackendType = "PHOENIX"
   7  	CashuBackendType   = "CASHU"
   8  	CLNBackendType     = "CLN"
   9  	BarkBackendType    = "BARK"
  10  )
  11  
  12  const (
  13  	OnchainAddressKey           = "OnchainAddress"
  14  	AutoSwapBalanceThresholdKey = "AutoSwapBalanceThreshold"
  15  	AutoSwapAmountKey           = "AutoSwapAmount"
  16  	AutoSwapDestinationKey      = "AutoSwapDestination"
  17  	AutoSwapXpubIndexStart      = "AutoSwapXpubIndexStart"
  18  )
  19  
  20  type AppConfig struct {
  21  	Relay                              string `envconfig:"RELAY" default:"wss://relay.mleku.dev,wss://relay.getalby.com,wss://relay2.getalby.com"`
  22  	LNBackendType                      string `envconfig:"LN_BACKEND_TYPE"`
  23  	LNDAddress                         string `envconfig:"LND_ADDRESS"`
  24  	LNDCertFile                        string `envconfig:"LND_CERT_FILE"`
  25  	LNDMacaroonFile                    string `envconfig:"LND_MACAROON_FILE"`
  26  	Workdir                            string `envconfig:"WORK_DIR"`
  27  	Port                               string `envconfig:"PORT" default:"8080"`
  28  	DatabaseUri                        string `envconfig:"DATABASE_URI" default:"nwc.db"`
  29  	LogLevel                           string `envconfig:"LOG_LEVEL" default:"4"`
  30  	LogToFile                          bool   `envconfig:"LOG_TO_FILE" default:"true"`
  31  	Network                            string `envconfig:"NETWORK"`
  32  	LDKNetwork                         string `envconfig:"LDK_NETWORK"`
  33  	LDKEsploraServer                   string `envconfig:"LDK_ESPLORA_SERVER" default:"https://electrs.getalbypro.com"` // TODO: remove LDK prefix
  34  	LDKElectrumServer                  string `envconfig:"LDK_ELECTRUM_SERVER"`
  35  	LDKGossipSource                    string `envconfig:"LDK_GOSSIP_SOURCE"`
  36  	LDKLogLevel                        string `envconfig:"LDK_LOG_LEVEL" default:"3"`
  37  	LDKMaxChannelSaturationPowerOfHalf uint8  `envconfig:"LDK_MAX_CHANNEL_SATURATION" default:"2"`
  38  	LDKMaxPathCount                    uint8  `envconfig:"LDK_MAX_PATH_COUNT" default:"5"`
  39  	LDKChannelMonitorWarningSizeBytes  uint64 `envconfig:"LDK_CHANNEL_MONITOR_WARNING_SIZE_BYTES" default:"5000000"`
  40  	LDKVssUrl                          string `envconfig:"LDK_VSS_URL" default:"https://vss.getalbypro.com/vss"`
  41  	LDKLiquiditySourceLsps2            string `envconfig:"LDK_LSPS2_ADDRESSES"`
  42  	LDKListeningAddresses              string `envconfig:"LDK_LISTENING_ADDRESSES" default:"[::]:9735"`
  43  	LDKAnnouncementAddresses           string `envconfig:"LDK_ANNOUNCEMENT_ADDRESSES"`
  44  	LDKTransientNetworkGraph           bool   `envconfig:"LDK_TRANSIENT_NETWORK_GRAPH" default:"false"`
  45  	RebalanceServiceUrl                string `envconfig:"REBALANCE_SERVICE_URL" default:"https://megalithic.me"`
  46  	LDKBitcoindRpcHost                 string `envconfig:"LDK_BITCOIND_RPC_HOST"`
  47  	LDKBitcoindRpcPort                 string `envconfig:"LDK_BITCOIND_RPC_PORT"`
  48  	LDKBitcoindRpcUser                 string `envconfig:"LDK_BITCOIND_RPC_USER"`
  49  	LDKBitcoindRpcPassword             string `envconfig:"LDK_BITCOIND_RPC_PASSWORD"`
  50  	MempoolApi                         string `envconfig:"MEMPOOL_API" default:"https://mempool.space/api"`
  51  	AlbyClientId                       string `envconfig:"ALBY_OAUTH_CLIENT_ID" default:"J2PbXS1yOf"`
  52  	AlbyClientSecret                   string `envconfig:"ALBY_OAUTH_CLIENT_SECRET" default:"rABK2n16IWjLTZ9M1uKU"`
  53  	BaseUrl                            string `envconfig:"BASE_URL"`
  54  	FrontendUrl                        string `envconfig:"FRONTEND_URL"`
  55  	SendEventsToAlby                   bool   `envconfig:"SEND_EVENTS_TO_ALBY" default:"true"`
  56  	AutoLinkAlbyAccount                bool   `envconfig:"AUTO_LINK_ALBY_ACCOUNT" default:"true"`
  57  	PhoenixdAddress                    string `envconfig:"PHOENIXD_ADDRESS"`
  58  	PhoenixdAuthorization              string `envconfig:"PHOENIXD_AUTHORIZATION"`
  59  	GoProfilerAddr                     string `envconfig:"GO_PROFILER_ADDR"`
  60  	EnableAdvancedSetup                bool   `envconfig:"ENABLE_ADVANCED_SETUP" default:"true"`
  61  	AutoUnlockPassword                 string `envconfig:"AUTO_UNLOCK_PASSWORD"`
  62  	Nip07Pubkey                        string `envconfig:"NIP07_PUBKEY"`
  63  	LogDBQueries                       bool   `envconfig:"LOG_DB_QUERIES" default:"false"`
  64  	BoltzApi                           string `envconfig:"BOLTZ_API" default:"https://api.boltz.exchange"`
  65  	HideUpdateBanner                   bool   `envconfig:"HIDE_UPDATE_BANNER" default:"false"`
  66  	CLNAddress                         string `envconfig:"CLN_ADDRESS"`
  67  	CLNLightningDir                    string `envconfig:"CLN_LIGHTNING_DIR"`
  68  	CLNAddressHold                     string `envconfig:"CLN_ADDRESS_HOLD"`
  69  	BarkServer                         string `envconfig:"BARK_SERVER" default:"https://ark.second.tech"`
  70  	BarkEsploraServer                  string `envconfig:"BARK_ESPLORA_SERVER" default:"https://mempool.second.tech/api"`
  71  	BarkServerAccessToken              string `envconfig:"BARK_SERVER_ACCESS_TOKEN"`
  72  	BarkLogLevel                       string `envconfig:"BARK_LOG_LEVEL" default:"3"`
  73  }
  74  
  75  func (c *AppConfig) IsDefaultClientId() bool {
  76  	return c.AlbyClientId == "J2PbXS1yOf"
  77  }
  78  
  79  func (c *AppConfig) GetBaseFrontendUrl() string {
  80  	url := c.FrontendUrl
  81  	if url == "" {
  82  		url = c.BaseUrl
  83  	}
  84  	return url
  85  }
  86  
  87  type Config interface {
  88  	Get(key string, encryptionKey string) (string, error)
  89  	SetIgnore(key string, value string, encryptionKey string) error
  90  	SetUpdate(key string, value string, encryptionKey string) error
  91  	LoadJWTSecret(encryptionKey string) error
  92  	GetJWTSecret() (string, error)
  93  	GetRelayUrls() []string
  94  	GetNetwork() string
  95  	GetMempoolUrl() string
  96  	GetEnv() *AppConfig
  97  	CheckUnlockPassword(password string) bool
  98  	IsUnlockPasswordCheckSet() (bool, error)
  99  	ChangeUnlockPassword(currentUnlockPassword string, newUnlockPassword string) error
 100  	SetAutoUnlockPassword(unlockPassword string) error
 101  	GetSessionSecret() (string, error)
 102  	GetNip07OwnerPubkey() string
 103  	SaveUnlockPasswordCheck(encryptionKey string) error
 104  	SetupCompleted() (bool, error)
 105  	GetCurrency() string
 106  	SetCurrency(value string) error
 107  	GetBitcoinDisplayFormat() string
 108  	SetBitcoinDisplayFormat(value string) error
 109  }
 110