diff --git a/README.md b/README.md index f3f9a54..0a811d1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Federated Lightning Address Server (with NIP57 Zap support) ## How to run -1. Download the binary from the releases page (or compile with `go build`) +1. Download the binary from the releases page (or compile with `go build` or if you want to compile for another system ,like a linux webserver: `env GOOS=linux GOARCH=amd64 go build` ) 2. Set the following environment variables somehow (using example values from bitmia.com): > The Nostr private key in the parameters should be in bench32 format (`nsec..`) and it should be a new one. It is needed to sign messages only, so does not need to be your main account key. @@ -42,7 +42,7 @@ Maybe ask for help on https://t.me/lnurl if you're in trouble. ## Status of the Fork: -- NIP57 for Nostr (ZAPS) works when using an LNBits or LND backend, other backends (sparko, lnpay, eclair, commando) still need verification of payments in waitforinvoice.go by API calls in order to sign the zap on Nostr. (Help appreciated, because I can't test them) +- NIP57 for Nostr ("Zaps") work when using an LNBits or LND backend, other backends (sparko, lnpay, eclair, commando) still need verification of payments in waitforinvoice.go by API calls in order to sign the zap on Nostr. (Help appreciated, because I can't test them) - Code needs some refactoring - Needs proper testing (especially in multi-user environment) - Credit for the inspiration by LightningTipBot code from @calle diff --git a/db.go b/db.go index 3ddf934..1cd0efd 100644 --- a/db.go +++ b/db.go @@ -14,16 +14,15 @@ import ( ) type Params struct { - Name string `json:"name"` - Domain string `json:"domain,omitempty"` - Kind string `json:"kind"` - Host string `json:"host"` - zapEventSerializedStr string `json:"zapEventSerializedStr"` - Key string `json:"key"` - Pak string `json:"pak"` - Waki string `json:"waki"` - NodeId string `json:"nodeid"` - Rune string `json:"rune"` + Name string `json:"name"` + Domain string `json:"domain,omitempty"` + Kind string `json:"kind"` + Host string `json:"host"` + Key string `json:"key"` + Pak string `json:"pak"` + Waki string `json:"waki"` + NodeId string `json:"nodeid"` + Rune string `json:"rune"` Pin string `json:"pin"` MinSendable string `json:"minSendable"` @@ -57,7 +56,7 @@ func SaveName( params.Domain = domain // check if the given data works - if inv, err = makeInvoice(params, 1000, &pin); err != nil { + if inv, err = makeInvoice(params, 1000, &pin, ""); err != nil { return "", "", fmt.Errorf("couldn't make an invoice with the given data: %w", err) } diff --git a/lnurl.go b/lnurl.go index 4112053..a132e38 100644 --- a/lnurl.go +++ b/lnurl.go @@ -109,6 +109,7 @@ func handleLNURL(w http.ResponseWriter, r *http.Request) { nostrPubkey = pub } + //serveLNURLpFirst json.NewEncoder(w).Encode(LNURLPayParamsCustom{ LNURLResponse: lnurl.LNURLResponse{Status: "OK"}, Callback: fmt.Sprintf("https://%s/.well-known/lnurlp/%s", domain, username), @@ -244,14 +245,14 @@ func serveLNURLpSecond(w http.ResponseWriter, params *Params, username string, a } } // calculate description hash from the serialized nostr event in makeinvoice.go - params.zapEventSerializedStr = zapEventSerializedStr + zapEventSerializedStr = zapEventSerializedStr } else { - params.zapEventSerializedStr = "" + zapEventSerializedStr = "" } var response LNURLPayValuesCustom - invoice, err := makeInvoice(params, amount_msat, nil) + invoice, err := makeInvoice(params, amount_msat, nil, zapEventSerializedStr) if err != nil { err = fmt.Errorf("Couldn't create invoice: %v", err.Error()) response = LNURLPayValuesCustom{ diff --git a/makeinvoice.go b/makeinvoice.go index 02b1da6..670a996 100644 --- a/makeinvoice.go +++ b/makeinvoice.go @@ -22,6 +22,7 @@ func makeInvoice( params *Params, msat int, pin *string, + zapEventSerializedStr string, ) (bolt11 string, err error) { // prepare params var backend makeinvoice.BackendParams @@ -70,9 +71,9 @@ func makeInvoice( // use this as the description for new accounts mip.Description = fmt.Sprintf("%s's PIN for '%s@%s' lightning address: %s", params.Domain, params.Name, params.Domain, *pin) } else { - //use zapEventSerializedStr if nip57 - if params.zapEventSerializedStr != "" { - mip.Description = params.zapEventSerializedStr + //use zapEventSerializedStr if nip57, else build hash descriptionhash from params + if zapEventSerializedStr != "" { + mip.Description = zapEventSerializedStr } else { // make the lnurlpay description_hash mip.Description = metaData(params).Encode()