Add nostr nip-05 registration with lnd invoices #1
3 changed files with 12 additions and 5 deletions
11
lnd/lnd.go
11
lnd/lnd.go
|
@ -1,8 +1,15 @@
|
||||||
package lnd
|
package lnd
|
||||||
|
|
||||||
import "github.com/davecgh/go-spew/spew"
|
import (
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
)
|
||||||
|
|
||||||
func Request(request []byte) (string, int, error) {
|
func Request(rKey string, request []byte) (string, int, error) {
|
||||||
|
//redis, err := redis.New("localhost:6379", "", redis.LndDb)
|
||||||
|
//if err != nil {
|
||||||
|
// return "", 0, errors.New("Failed to connect to redis")
|
||||||
|
//}
|
||||||
|
spew.Dump(rKey)
|
||||||
spew.Dump(request)
|
spew.Dump(request)
|
||||||
return "x", 1, nil
|
return "x", 1, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ type NostrRequest struct {
|
||||||
func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
|
func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "GET":
|
||||||
http.ServeFile(w, r, "nostr/form.html")
|
http.ServeFile(w, r, "html/nostr_form.html")
|
||||||
case "POST":
|
case "POST":
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
rKey := getRkey(r.FormValue("Name"), getHostname(r.Host))
|
rKey := getRkey(r.FormValue("Name"), getHostname(r.Host))
|
||||||
|
@ -66,7 +66,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
jsonUser, _ := json.Marshal(user)
|
jsonUser, _ := json.Marshal(user)
|
||||||
|
|
||||||
// generate the payment request
|
// generate the payment request
|
||||||
paymentReq, exp, err := lnd.Request(jsonUser)
|
paymentReq, exp, err := lnd.Request(rKey, jsonUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusServiceUnavailable)
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
return
|
return
|
||||||
|
@ -122,7 +122,7 @@ func AddNostrAddr(n NostrRequest) {
|
||||||
|
|
||||||
r, err := redis.New("localhost:6379", "", redis.NostrDb)
|
r, err := redis.New("localhost:6379", "", redis.NostrDb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("FAILED")
|
fmt.Println("Failed to connect to redis")
|
||||||
}
|
}
|
||||||
nameKey := getRkey(n.Name, n.Hostname)
|
nameKey := getRkey(n.Name, n.Hostname)
|
||||||
err = r.Client.Set(nameKey, jsonUser, redis.NostrDb).Err()
|
err = r.Client.Set(nameKey, jsonUser, redis.NostrDb).Err()
|
||||||
|
|
Loading…
Reference in a new issue