mirror of
https://github.com/believethehype/nostdress.git
synced 2026-07-05 15:38:10 -07:00
removed zapEventSerializedStr from params, resetting them to original state (refactor)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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{
|
||||
|
||||
+4
-3
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user