Add nostr nip-05 registration with lnd invoices #1
2 changed files with 8 additions and 4 deletions
|
@ -1,15 +1,18 @@
|
||||||
package lnd
|
package lnd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Request(rKey string, request []byte) (string, error) {
|
func Request(rKey string, request []byte, exp time.Duration) (string, error) {
|
||||||
//redis, err := redis.New("localhost:6379", "", redis.LndDb)
|
//redis, err := redis.New("localhost:6379", "", redis.LndDb)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// return "", 0, errors.New("Failed to connect to redis")
|
// return "", 0, errors.New("Failed to connect to redis")
|
||||||
//}
|
//}
|
||||||
spew.Dump(rKey)
|
spew.Dump(rKey)
|
||||||
|
spew.Dump(exp)
|
||||||
spew.Dump(request)
|
spew.Dump(request)
|
||||||
return "x", nil
|
return "x", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,13 +69,14 @@ 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, err := lnd.Request(rKey, jsonUser)
|
exp := time.Until(time.Now().Add(time.Minute * 15))
|
||||||
|
paymentReq, err := lnd.Request(rKey, jsonUser, exp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusServiceUnavailable)
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
requestKey := getRkey("requested", r.FormValue("Name"), getHostname(r.Host))
|
requestKey := getRkey("requested", r.FormValue("Name"), getHostname(r.Host))
|
||||||
err = redisCli.Client.Set(ctx, requestKey, jsonUser, 15*time.Minute).Err()
|
err = redisCli.Client.Set(ctx, requestKey, jsonUser, exp).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("FAILED")
|
fmt.Println("FAILED")
|
||||||
}
|
}
|
||||||
|
@ -151,7 +152,7 @@ func convertNpubToHex(npub string) (string, error) {
|
||||||
}
|
}
|
||||||
_, hex, err := nip19.Decode(npub)
|
_, hex, err := nip19.Decode(npub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
spew.Dump(hex)
|
return "", errors.New("Unable to decode npub")
|
||||||
}
|
}
|
||||||
|
|
||||||
return hex.(string), nil
|
return hex.(string), nil
|
||||||
|
|
Loading…
Reference in a new issue