mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-02-23 13:54:25 +01:00
move limits struct out of lnd package
This commit is contained in:
@@ -37,8 +37,8 @@ type Config struct {
|
||||
MaxSendAmount int64 `envconfig:"MAX_SEND_AMOUNT" default:"0"`
|
||||
MaxAccountBalance int64 `envconfig:"MAX_ACCOUNT_BALANCE" default:"0"`
|
||||
MaxFeeAmount int64 `envconfig:"MAX_FEE_AMOUNT" default:"5000"`
|
||||
MaxSendVolume int64 `envconfig:"MAX_SEND_VOLUME" default:"0"` //0 means the volume check is disabled by default
|
||||
MaxReceiveVolume int64 `envconfig:"MAX_RECEIVE_VOLUME" default:"0"` //0 means the volume check is disabled by default
|
||||
MaxSendVolume int64 `envconfig:"MAX_SEND_VOLUME" default:"0"` //0 means the volume check is disabled by default
|
||||
MaxReceiveVolume int64 `envconfig:"MAX_RECEIVE_VOLUME" default:"0"` //0 means the volume check is disabled by default
|
||||
MaxVolumePeriod int64 `envconfig:"MAX_VOLUME_PERIOD" default:"2592000"` //in seconds, default 1 month
|
||||
RabbitMQUri string `envconfig:"RABBITMQ_URI"`
|
||||
RabbitMQLndhubInvoiceExchange string `envconfig:"RABBITMQ_INVOICE_EXCHANGE" default:"lndhub_invoice"`
|
||||
@@ -48,7 +48,13 @@ type Config struct {
|
||||
RabbitMQPaymentConsumerQueueName string `envconfig:"RABBITMQ_PAYMENT_CONSUMER_QUEUE_NAME" default:"lnd_payment_consumer"`
|
||||
Branding BrandingConfig
|
||||
}
|
||||
|
||||
type Limits struct {
|
||||
MaxSendVolume int64
|
||||
MaxSendAmount int64
|
||||
MaxReceiveVolume int64
|
||||
MaxReceiveAmount int64
|
||||
MaxAccountBalance int64
|
||||
}
|
||||
type BrandingConfig struct {
|
||||
Title string `envconfig:"BRANDING_TITLE" default:"LndHub.go - Alby Lightning"`
|
||||
Desc string `envconfig:"BRANDING_DESC" default:"Alby server for the Lightning Network"`
|
||||
|
||||
@@ -182,7 +182,7 @@ func (svc *LndhubService) CheckIncomingPaymentAllowed(c echo.Context, amount, us
|
||||
if limits.MaxReceiveAmount > 0 {
|
||||
if amount > limits.MaxReceiveAmount {
|
||||
svc.Logger.Errorf("Max receive amount exceeded for user_id %d", userId)
|
||||
return &responses.ReceiveExceededError, nil
|
||||
return &responses.ReceiveExceededError, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,28 +292,28 @@ func (svc *LndhubService) GetVolumeOverPeriod(ctx context.Context, userId int64,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (svc *LndhubService) GetLimits(c echo.Context) (limits *lnd.Limits) {
|
||||
limits = &lnd.Limits{
|
||||
func (svc *LndhubService) GetLimits(c echo.Context) (limits *Limits) {
|
||||
limits = &Limits{
|
||||
MaxSendVolume: svc.Config.MaxSendVolume,
|
||||
MaxSendAmount: svc.Config.MaxSendAmount,
|
||||
MaxReceiveVolume: svc.Config.MaxReceiveVolume,
|
||||
MaxReceiveAmount: svc.Config.MaxReceiveAmount,
|
||||
MaxAccountBalance: svc.Config.MaxAccountBalance,
|
||||
MaxSendAmount: svc.Config.MaxSendAmount,
|
||||
MaxReceiveVolume: svc.Config.MaxReceiveVolume,
|
||||
MaxReceiveAmount: svc.Config.MaxReceiveAmount,
|
||||
MaxAccountBalance: svc.Config.MaxAccountBalance,
|
||||
}
|
||||
if val, ok := c.Get("MaxSendVolume").(int64); ok && val > 0 {
|
||||
limits.MaxSendVolume = val
|
||||
limits.MaxSendVolume = val
|
||||
}
|
||||
if val, ok := c.Get("MaxSendAmount").(int64); ok && val > 0 {
|
||||
limits.MaxSendAmount = val
|
||||
limits.MaxSendAmount = val
|
||||
}
|
||||
if val, ok := c.Get("MaxReceiveVolume").(int64); ok && val > 0 {
|
||||
limits.MaxReceiveVolume = val
|
||||
limits.MaxReceiveVolume = val
|
||||
}
|
||||
if val, ok := c.Get("MaxReceiveAmount").(int64); ok && val > 0 {
|
||||
limits.MaxReceiveAmount = val
|
||||
limits.MaxReceiveAmount = val
|
||||
}
|
||||
if val, ok := c.Get("MaxAccountBalance").(int64); ok && val > 0 {
|
||||
limits.MaxAccountBalance = val
|
||||
limits.MaxAccountBalance = val
|
||||
}
|
||||
|
||||
return limits
|
||||
|
||||
@@ -22,14 +22,6 @@ type Config struct {
|
||||
LNDClusterPubkeys string `envconfig:"LND_CLUSTER_PUBKEYS"` //comma-seperated list of public keys of the cluster
|
||||
}
|
||||
|
||||
type Limits struct {
|
||||
MaxSendVolume int64
|
||||
MaxSendAmount int64
|
||||
MaxReceiveVolume int64
|
||||
MaxReceiveAmount int64
|
||||
MaxAccountBalance int64
|
||||
}
|
||||
|
||||
func LoadConfig() (c *Config, err error) {
|
||||
c = &Config{}
|
||||
err = envconfig.Process("", c)
|
||||
|
||||
Reference in New Issue
Block a user