mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-02-23 22:04:23 +01:00
Trying to use lnrpc in a controller
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user