add option to have external port
This commit is contained in:
parent
3a2096345d
commit
6ef61fe1af
6 changed files with 61 additions and 25 deletions
|
|
@ -2,13 +2,14 @@ package lnurlp
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/boltcard/boltcard/db"
|
||||
"github.com/boltcard/boltcard/lnd"
|
||||
"github.com/boltcard/boltcard/resp_err"
|
||||
"github.com/gorilla/mux"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Callback(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -37,6 +38,11 @@ func Callback(w http.ResponseWriter, r *http.Request) {
|
|||
}).Info("lnurlp_callback")
|
||||
|
||||
domain := db.Get_setting("HOST_DOMAIN")
|
||||
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
|
||||
hostdomainsuffix := ""
|
||||
if hostdomainPort != "" {
|
||||
hostdomainsuffix = ":" + hostdomainPort
|
||||
}
|
||||
if r.Host != domain {
|
||||
log.Warn("wrong host domain")
|
||||
resp_err.Write(w)
|
||||
|
|
@ -52,7 +58,7 @@ func Callback(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
amount_sat := amount_msat / 1000
|
||||
|
||||
metadata := "[[\"text/identifier\",\"" + name + "@" + domain + "\"],[\"text/plain\",\"bolt card deposit\"]]"
|
||||
metadata := "[[\"text/identifier\",\"" + name + "@" + domain + hostdomainsuffix + "\"],[\"text/plain\",\"bolt card deposit\"]]"
|
||||
pr, r_hash, err := lnd.Add_invoice(amount_sat, metadata)
|
||||
if err != nil {
|
||||
log.Warn("could not add_invoice")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package lnurlp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/boltcard/boltcard/db"
|
||||
"github.com/boltcard/boltcard/resp_err"
|
||||
"github.com/gorilla/mux"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func Response(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -26,6 +27,11 @@ func Response(w http.ResponseWriter, r *http.Request) {
|
|||
// look up domain setting (HOST_DOMAIN)
|
||||
|
||||
domain := db.Get_setting("HOST_DOMAIN")
|
||||
hostdomainPort := db.Get_setting("HOST_DOMAIN_PORT")
|
||||
hostdomainsuffix := ""
|
||||
if hostdomainPort != "" {
|
||||
hostdomainsuffix = ":" + hostdomainPort
|
||||
}
|
||||
if r.Host != domain {
|
||||
log.Warn("wrong host domain")
|
||||
resp_err.Write(w)
|
||||
|
|
@ -47,10 +53,10 @@ func Response(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
metadata := "[[\\\"text/identifier\\\",\\\"" + name + "@" + domain + "\\\"],[\\\"text/plain\\\",\\\"bolt card deposit\\\"]]"
|
||||
metadata := "[[\\\"text/identifier\\\",\\\"" + name + "@" + domain + hostdomainsuffix + "\\\"],[\\\"text/plain\\\",\\\"bolt card deposit\\\"]]"
|
||||
|
||||
jsonData := []byte(`{"status":"OK",` +
|
||||
`"callback":"https://` + domain + `/lnurlp/` + name + `",` +
|
||||
`"callback":"https://` + domain + hostdomainsuffix + `/lnurlp/` + name + `",` +
|
||||
`"tag":"payRequest",` +
|
||||
`"maxSendable":1000000000,` +
|
||||
`"minSendable":1000,` +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue