mirror of
https://github.com/believethehype/nostdress.git
synced 2026-06-14 05:03:34 -07:00
@@ -9,7 +9,7 @@ Federated Lightning Address Server (with NIP57 Zap support)
|
||||
|
||||
New parameters in this fork:
|
||||
|
||||
> 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 and should not be your main account key.
|
||||
> The (`NOSTR_PRIVATE_KEY`) in the parameters should be in Bech32 format (`nsec..`) and it should be a new one. It is needed to sign messages only, so does not need and should not be your main account key.
|
||||
|
||||
> (`NIP05`) will run a NIPO5 instance so that users that register with their NPUB can use their Lightning address for validation in Nostr as well.
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ func handleLNURL(w http.ResponseWriter, r *http.Request) {
|
||||
if len(s.NostrPrivateKey) > 0 {
|
||||
//allows users to use nsec keys, work with hex internally.
|
||||
//This can be any private key, not necessarily from the user.
|
||||
nostrPrivkeyHex = DecodeBench32(s.NostrPrivateKey)
|
||||
nostrPrivkeyHex = DecodeBech32(s.NostrPrivateKey)
|
||||
allowNostr = true
|
||||
pk := nostrPrivkeyHex
|
||||
pub, _ := nostr.GetPublicKey(pk)
|
||||
@@ -277,9 +277,9 @@ func serveLNURLpSecond(w http.ResponseWriter, params *Params, username string, a
|
||||
if zapEvent.Sig != "" {
|
||||
// TODO: Handle the err
|
||||
nip57Receipt, err = CreateNostrReceipt(zapEvent, invoice)
|
||||
sender = "@" + EncodeBench32Public(zapEvent.PubKey)
|
||||
sender = "@" + EncodeBech32Public(zapEvent.PubKey)
|
||||
if zapEvent.Tags.GetFirst([]string{"e"}) != nil {
|
||||
note = "@" + EncodeBench32Note(zapEvent.Tags.GetFirst([]string{"e"}).Value())
|
||||
note = "@" + EncodeBech32Note(zapEvent.Tags.GetFirst([]string{"e"}).Value())
|
||||
}
|
||||
if zapEvent.Tags.GetFirst([]string{"anon"}) != nil {
|
||||
if zapEvent.Tags.GetFirst([]string{"anon"}).Value() == "" {
|
||||
|
||||
@@ -46,7 +46,7 @@ func Nip57DescriptionHash(zapEventSerialized string) string {
|
||||
return hashString
|
||||
}
|
||||
|
||||
func DecodeBench32(key string) string {
|
||||
func DecodeBech32(key string) string {
|
||||
if _, v, err := nip19.Decode(key); err == nil {
|
||||
return v.(string)
|
||||
}
|
||||
@@ -54,21 +54,21 @@ func DecodeBench32(key string) string {
|
||||
|
||||
}
|
||||
|
||||
func EncodeBench32Public(key string) string {
|
||||
func EncodeBech32Public(key string) string {
|
||||
if v, err := nip19.EncodePublicKey(key); err == nil {
|
||||
return v
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
func EncodeBench32Private(key string) string {
|
||||
func EncodeBech32Private(key string) string {
|
||||
if v, err := nip19.EncodePrivateKey(key); err == nil {
|
||||
return v
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
func EncodeBench32Note(key string) string {
|
||||
func EncodeBech32Note(key string) string {
|
||||
if v, err := nip19.EncodeNote(key); err == nil {
|
||||
return v
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func sendMessage(receiverKey string, message string) {
|
||||
|
||||
var relays []string
|
||||
var tags nostr.Tags
|
||||
reckey := DecodeBench32(receiverKey)
|
||||
reckey := DecodeBech32(receiverKey)
|
||||
tags = append(tags, nostr.Tag{"p", reckey})
|
||||
|
||||
//references, err := optSlice(opts, "--reference")
|
||||
@@ -91,7 +91,7 @@ func sendMessage(receiverKey string, message string) {
|
||||
//}
|
||||
|
||||
// parse and encrypt content
|
||||
privkeyhex := DecodeBench32(s.NostrPrivateKey)
|
||||
privkeyhex := DecodeBech32(s.NostrPrivateKey)
|
||||
pubkey, _ := nostr.GetPublicKey(privkeyhex)
|
||||
|
||||
sharedSecret, err := nip04.ComputeSharedSecret(reckey, privkeyhex)
|
||||
@@ -155,7 +155,7 @@ func handleNip05(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
nostrnpubHex := DecodeBench32(params.Npub)
|
||||
nostrnpubHex := DecodeBech32(params.Npub)
|
||||
response := map[string]interface{}{
|
||||
"names": map[string]interface{}{
|
||||
username: nostrnpubHex,
|
||||
|
||||
Reference in New Issue
Block a user