Set up expiration
This commit is contained in:
parent
dc21d3850d
commit
1431887c04
2 changed files with 8 additions and 4 deletions
|
@ -1,15 +1,18 @@
|
|||
package lnd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"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)
|
||||
//if err != nil {
|
||||
// return "", 0, errors.New("Failed to connect to redis")
|
||||
//}
|
||||
spew.Dump(rKey)
|
||||
spew.Dump(exp)
|
||||
spew.Dump(request)
|
||||
return "x", nil
|
||||
}
|
||||
|
|
|
@ -69,13 +69,14 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
|
|||
jsonUser, _ := json.Marshal(user)
|
||||
|
||||
// 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 {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
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 {
|
||||
fmt.Println("FAILED")
|
||||
}
|
||||
|
@ -151,7 +152,7 @@ func convertNpubToHex(npub string) (string, error) {
|
|||
}
|
||||
_, hex, err := nip19.Decode(npub)
|
||||
if err != nil {
|
||||
spew.Dump(hex)
|
||||
return "", errors.New("Unable to decode npub")
|
||||
}
|
||||
|
||||
return hex.(string), nil
|
||||
|
|
Loading…
Reference in a new issue