30 lines
912 B
Go
30 lines
912 B
Go
// internal/utils/nip19.go
|
|
package utils
|
|
|
|
import (
|
|
"github.com/nbd-wtf/go-nostr/nip19"
|
|
)
|
|
|
|
// EncodeEventAsNevent encodes an event ID and relays into a NIP-19 "nevent" identifier
|
|
func EncodeEventAsNevent(eventID string, relays []string, authorPubkey string) (string, error) {
|
|
// Use the direct function signature that your version of nip19 expects
|
|
return nip19.EncodeEvent(eventID, relays, authorPubkey)
|
|
}
|
|
|
|
// EncodeEventAsNote encodes an event ID into a NIP-19 "note" identifier (simpler)
|
|
func EncodeEventAsNote(eventID string) (string, error) {
|
|
note, err := nip19.EncodeNote(eventID)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return note, nil
|
|
}
|
|
|
|
// EncodePubkey encodes a public key into a NIP-19 "npub" identifier
|
|
func EncodePubkey(pubkey string) (string, error) {
|
|
npub, err := nip19.EncodePublicKey(pubkey)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return npub, nil
|
|
} |