fix inconsistency in name saving.

This commit is contained in:
fiatjaf 2021-08-20 10:30:20 -03:00
parent 42154594c9
commit d79d5351ff
2 changed files with 8 additions and 2 deletions

4
db.go
View File

@ -21,10 +21,10 @@ type Params struct {
} }
func SaveName(name string, params *Params, providedPin string) (pin string, err error) { func SaveName(name string, params *Params, providedPin string) (pin string, err error) {
key := []byte(name + "@" + s.Domain) key := []byte(name)
mac := hmac.New(sha256.New, []byte(s.Secret)) mac := hmac.New(sha256.New, []byte(s.Secret))
mac.Write(key) mac.Write([]byte(name + "@" + s.Domain))
pin = hex.EncodeToString(mac.Sum(nil)) pin = hex.EncodeToString(mac.Sum(nil))
if _, closer, err := db.Get(key); err == nil { if _, closer, err := db.Get(key); err == nil {

View File

@ -2,6 +2,7 @@ package main
import ( import (
"crypto/sha256" "crypto/sha256"
"encoding/hex"
"strconv" "strconv"
"time" "time"
@ -50,6 +51,11 @@ func makeInvoice(params *Params, msat int) (bolt11 string, err error) {
} }
} }
log.Debug().Int("msatoshi", msat).
Interface("backend", backend).
Str("description_hash", hex.EncodeToString(h[:])).
Msg("generating invoice")
// actually generate the invoice // actually generate the invoice
return makeinvoice.MakeInvoice(makeinvoice.Params{ return makeinvoice.MakeInvoice(makeinvoice.Params{
Msatoshi: int64(msat), Msatoshi: int64(msat),