Documentation
¶
Overview ¶
Package utils holds small helpers shared across this SDK's NIP and relay packages: event/tag validation, key management, NIP-05/LUD-16 URL helpers, logging, and LNURL decoding. It has no NIP of its own — it exists to avoid duplicating this plumbing in every package that needs it.
Index ¶
- Variables
- func EscapeJSONString(s string) string
- func FindUniqueEventTag(tags [][]string, tagName string) ([]string, error)
- func FindUniqueEventTagValue(tags [][]string, tagName string) (string, error)
- func GetDomainOnly(id string) string
- func GetFullHTTPURL(r *http.Request) string
- func GetLud16URL(lud16 string) string
- func GetNip05URL(nip05 string) string
- func GetPublicKey(privKeyHex string) (string, error)
- func InitLogger()
- func IsValidPictureURL(u string) bool
- func LookupEventTag(tags [][]string, tagName string) ([][]string, bool)
- func MarshalTags(tags [][]string) ([]byte, error)
- func ParseATag(tag string) (kind int, pubKey, dValue string, err error)
- func RecoverPanic(logger zerolog.Logger)
- func UnmarshalJSON(data []byte, v interface{}) error
- func Validate32Key(hexStr string) error
- func ValidateEventTags(tags [][]string) error
- func ValidateFilterTag(name string, vals []string) error
- func ValidateFilterTags(tags map[string][]string) error
- func ValidateIndexableTag(name string) error
- func ValidateKind(kind int) error
- func ValidateLNURL(lnurlStr string) error
- func ValidateStrKind(skind string) (int, error)
- func VerifyNip05(r io.Reader, pubkey, nip05 string) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrTagNotFound = errors.New("tag not found") ErrTagNotUnique = errors.New("multiple tags with the same name found") )
Functions ¶
func EscapeJSONString ¶
func FindUniqueEventTag ¶
func FindUniqueEventTagValue ¶
func GetDomainOnly ¶
GetDomainOnly extracts the domain from a NIP-05 or LUD-16 identifier.
func GetFullHTTPURL ¶
GetFullHTTPURL recreates the absolute URL string from an incoming HTTP request to strictly validate exactly what the client signed for NIP-98 matching.
func GetLud16URL ¶
GetLud16URL returns the URL to fetch the LNURL-pay JSON for a given LUD-16 identifier.
func GetNip05URL ¶
GetNip05URL returns the URL to fetch the NIP-05 JSON for a given identifier.
func GetPublicKey ¶
func InitLogger ¶
func InitLogger()
InitLogger points the process-global zerolog logger at a colored console writer. It's a convenience for standalone-binary consumers and must only be called explicitly from a main()/cmd entrypoint -- never from a package init(), which would silently reconfigure global logging state as an import side effect for every consumer of that package.
func IsValidPictureURL ¶
IsValidPictureURL performs a basic check to see if a string looks like a valid HTTP or HTTPS URL.
func MarshalTags ¶
func RecoverPanic ¶
RecoverPanic recovers a panic in the calling goroutine and logs it with a stack trace through logger. It intentionally does not re-panic or terminate the process: callers defer this specifically to contain a panic to the one goroutine (e.g. a single client session) without taking down the whole embedding application.
func UnmarshalJSON ¶
UnmarshalJSON inlines a simple JSON unmarshaler and handles errors.
func Validate32Key ¶
func ValidateEventTags ¶
func ValidateFilterTag ¶
func ValidateFilterTags ¶
func ValidateIndexableTag ¶
func ValidateKind ¶
func ValidateLNURL ¶
ValidateLNURL decodes a bech32 LNURL string and validates the resulting URL.
func ValidateStrKind ¶
Types ¶
This section is empty.