Trying to use lnrpc in a controller

This commit is contained in:
Michael Bumann
2022-01-17 22:52:10 +01:00
parent 7c007791ec
commit b191d19707

View File

@@ -1,10 +1,12 @@
package controllers
import (
"context"
"net/http"
"github.com/bumi/lndhub.go/lib"
"github.com/labstack/echo/v4"
"github.com/lightningnetwork/lnd/lnrpc"
)
// BalanceController : BalanceController struct
@@ -14,6 +16,13 @@ type BalanceController struct{}
func (BalanceController) Balance(c echo.Context) error {
ctx := c.(*lib.LndhubContext)
c.Logger().Warn(ctx.User.ID)
lndClient := *ctx.LndClient
getInfo, err := lndClient.GetInfo(context.TODO(), &lnrpc.GetInfoRequest{})
if err != nil {
panic(err)
}
c.Logger().Infof("Connected to LND: %s - %s", getInfo.Alias, getInfo.IdentityPubkey)
return c.JSON(http.StatusOK, echo.Map{
"BTC": echo.Map{
"AvailableBalance": 1,