Skip to content

Commit

Permalink
Merge pull request #30 from bumi/feature/support-forwarded-for-header
Browse files Browse the repository at this point in the history
Generate lightning address host either from the x-forwarded-for header or from the request host
  • Loading branch information
bumi authored Nov 17, 2021
2 parents 6f2b72c + d1be2e2 commit b100455
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lnme.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,18 @@ func main() {

if !cfg.Bool("disable-ln-address") {
lnurlHandler := func(c echo.Context) error {
host := c.Request().Host
if c.Request().Header.Get(echo.HeaderXForwardedFor) != "" {
host = c.Request().Header.Get(echo.HeaderXForwardedFor)
}
name := c.Param("name")
lightningAddress := name + "@" + c.Request().Host
lightningAddress := name + "@" + host
lnurlMetadata := "[[\"text/identifier\", \"" + lightningAddress + "\"], [\"text/plain\", \"Sats for " + lightningAddress + "\"]]"

if amount := c.QueryParam("amount"); amount == "" {
lnurlPayResponse1 := lnurl.LNURLPayResponse1{
LNURLResponse: lnurl.LNURLResponse{Status: "OK"},
Callback: fmt.Sprintf("%s://%s%s", c.Scheme(), c.Request().Host, c.Request().URL.Path),
Callback: fmt.Sprintf("%s://%s%s", c.Scheme(), host, c.Request().URL.Path),
MinSendable: 1000,
MaxSendable: 100000000,
EncodedMetadata: lnurlMetadata,
Expand Down

0 comments on commit b100455

Please sign in to comment.