diff --git a/integration_tests/internal_payment_test.go b/integration_tests/internal_payment_test.go index da521241..4b2c721d 100644 --- a/integration_tests/internal_payment_test.go +++ b/integration_tests/internal_payment_test.go @@ -204,7 +204,7 @@ func (suite *PaymentTestSuite) TestIncomingExceededChecks() { assert.Equal(suite.T(), responses.BalanceExceededError.Message, resp.Message) //change the config back and add sats, it should work now - suite.service.Config.MaxAccountBalance = 0 + suite.service.Config.MaxAccountBalance = -1 invoiceResponse = suite.createAddInvoiceReq(aliceFundingSats, "integration test internal payment alice", suite.aliceToken) err = suite.mlnd.mockPaidInvoice(invoiceResponse, 0, false, nil) assert.NoError(suite.T(), err) diff --git a/integration_tests/util.go b/integration_tests/util.go index 6c0ffc90..04178cfc 100644 --- a/integration_tests/util.go +++ b/integration_tests/util.go @@ -49,8 +49,11 @@ const ( func LndHubTestServiceInit(lndClientMock lnd.LightningClientWrapper) (svc *service.LndhubService, err error) { dbUri, ok := os.LookupEnv("DATABASE_URI") if !ok { - dbUri = "postgresql://user:password@localhost/lndhub?sslmode=disable" + dbUri = "postgresql://im-adithya:password@localhost:5432/lndhub?sslmode=disable" } + dc := &service.Config{} + fmt.Println("dc.MaxSendAmount") + fmt.Println(dc.MaxSendAmount) c := &service.Config{ DatabaseUri: dbUri, DatabaseMaxConns: 1, @@ -64,6 +67,7 @@ func LndHubTestServiceInit(lndClientMock lnd.LightningClientWrapper) (svc *servi MaxSendVolume: -1, MaxReceiveAmount: -1, MaxReceiveVolume: -1, + MaxAccountBalance: -1, } rabbitmqUri, ok := os.LookupEnv("RABBITMQ_URI") diff --git a/lib/service/config.go b/lib/service/config.go index 9adcde47..7e0cf5ad 100644 --- a/lib/service/config.go +++ b/lib/service/config.go @@ -37,7 +37,7 @@ type Config struct { MinPasswordEntropy int `envconfig:"MIN_PASSWORD_ENTROPY" default:"0"` MaxReceiveAmount int64 `envconfig:"MAX_RECEIVE_AMOUNT" default:"-1"` MaxSendAmount int64 `envconfig:"MAX_SEND_AMOUNT" default:"-1"` - MaxAccountBalance int64 `envconfig:"MAX_ACCOUNT_BALANCE" default:"0"` + MaxAccountBalance int64 `envconfig:"MAX_ACCOUNT_BALANCE" default:"-1"` MaxFeeAmount int64 `envconfig:"MAX_FEE_AMOUNT" default:"5000"` MaxSendVolume int64 `envconfig:"MAX_SEND_VOLUME" default:"-1"` //-1 means the volume check is disabled by default MaxReceiveVolume int64 `envconfig:"MAX_RECEIVE_VOLUME" default:"-1"` //-1 means the volume check is disabled by default diff --git a/lib/service/user.go b/lib/service/user.go index 93f53b34..6b21bd81 100644 --- a/lib/service/user.go +++ b/lib/service/user.go @@ -221,7 +221,7 @@ func (svc *LndhubService) CheckIncomingPaymentAllowed(c echo.Context, amount, us } } - if limits.MaxAccountBalance > 0 { + if limits.MaxAccountBalance >= 0 { currentBalance, err := svc.CurrentUserBalance(c.Request().Context(), userId) if err != nil { svc.Logger.Errorj( @@ -338,8 +338,8 @@ func (svc *LndhubService) GetLimits(c echo.Context) (limits *Limits) { if val, ok := c.Get("MaxReceiveAmount").(*int64); ok && val != nil { limits.MaxReceiveAmount = *val } - if val, ok := c.Get("MaxAccountBalance").(int64); ok && val > 0 { - limits.MaxAccountBalance = val + if val, ok := c.Get("MaxAccountBalance").(*int64); ok && val != nil { + limits.MaxAccountBalance = *val } return limits diff --git a/lib/tokens/jwt.go b/lib/tokens/jwt.go index 9b05813f..bf92b13b 100644 --- a/lib/tokens/jwt.go +++ b/lib/tokens/jwt.go @@ -21,7 +21,7 @@ type jwtCustomClaims struct { MaxSendAmount *int64 `json:"maxSendAmount,omitempty"` MaxReceiveVolume *int64 `json:"maxReceiveVolume,omitempty"` MaxReceiveAmount *int64 `json:"maxReceiveAmount,omitempty"` - MaxAccountBalance int64 `json:"maxAccountBalance"` + MaxAccountBalance *int64 `json:"maxAccountBalance,omitempty"` jwt.StandardClaims }