Compare commits
5 Commits
5c4baedb9d
...
c5554cb9ca
Author | SHA1 | Date | |
---|---|---|---|
c5554cb9ca | |||
0a10fcc109 | |||
79d473b0f5 | |||
9c13048fb6 | |||
0eb37e8e9d |
@ -11,6 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ekzyis/zaply/lightning"
|
"github.com/ekzyis/zaply/lightning"
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Phoenixd struct {
|
type Phoenixd struct {
|
||||||
@ -96,3 +97,18 @@ func (p *Phoenixd) CreateInvoice(msats int64, description string) (lightning.Bol
|
|||||||
|
|
||||||
return lightning.Bolt11(response.Serialized), nil
|
return lightning.Bolt11(response.Serialized), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WebhookHandler(c echo.Context) error {
|
||||||
|
var webhook struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
AmountSat int64 `json:"amountSat"`
|
||||||
|
PaymentHash string `json:"paymentHash"`
|
||||||
|
}
|
||||||
|
if err := c.Bind(&webhook); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("webhook: %+v", webhook)
|
||||||
|
|
||||||
|
return c.NoContent(http.StatusOK)
|
||||||
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/ekzyis/zaply/env"
|
"github.com/ekzyis/zaply/env"
|
||||||
"github.com/ekzyis/zaply/lightning/phoenixd"
|
"github.com/ekzyis/zaply/lightning/phoenixd"
|
||||||
"github.com/ekzyis/zaply/lnurl"
|
"github.com/ekzyis/zaply/lnurl"
|
||||||
@ -17,16 +20,25 @@ func NewServer() *Server {
|
|||||||
Echo: echo.New(),
|
Echo: echo.New(),
|
||||||
}
|
}
|
||||||
|
|
||||||
p := phoenixd.NewPhoenixd(
|
|
||||||
phoenixd.WithPhoenixdURL(env.PhoenixdURL),
|
|
||||||
phoenixd.WithPhoenixdLimitedAccessToken(env.PhoenixdLimitedAccessToken),
|
|
||||||
)
|
|
||||||
|
|
||||||
s.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
s.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||||
Format: "${time_custom} ${method} ${uri} ${status}\n",
|
Format: "${time_custom} ${method} ${uri} ${status}\n",
|
||||||
CustomTimeFormat: "2006-01-02 15:04:05.00000-0700",
|
CustomTimeFormat: "2006-01-02 15:04:05.00000-0700",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
webhookPath := "/overlay/webhook"
|
||||||
|
webhookUrl, err := url.JoinPath(env.PublicUrl, webhookPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
p := phoenixd.NewPhoenixd(
|
||||||
|
phoenixd.WithPhoenixdURL(env.PhoenixdURL),
|
||||||
|
phoenixd.WithPhoenixdLimitedAccessToken(env.PhoenixdLimitedAccessToken),
|
||||||
|
phoenixd.WithPhoenixdWebhookUrl(webhookUrl),
|
||||||
|
)
|
||||||
|
|
||||||
|
s.POST(webhookPath, phoenixd.WebhookHandler)
|
||||||
|
|
||||||
lnurl.Router(s.Echo, p)
|
lnurl.Router(s.Echo, p)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user