utils

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeNpub

func DecodeNpub(npub string) (string, error)

DecodeNpub decodes a Bech32 encoded npub to its corresponding pubkey

func DetermineEventCategory

func DetermineEventCategory(kind int) string

func EnsureFileExists

func EnsureFileExists(filePath, examplePath string)

func FetchPubkeysFromDomains

func FetchPubkeysFromDomains(domains []string) ([]string, error)

FetchPubkeysFromDomains fetches nostr.json pubkeys from multiple domains with caching.

func GetClientIP

func GetClientIP(r *http.Request) string

func LoadRelayMetadata

func LoadRelayMetadata(filename string) error

func LoadRelayMetadataJSON

func LoadRelayMetadataJSON() error

func RelayInfoHandler

func RelayInfoHandler(w http.ResponseWriter, r *http.Request)

func SendToBackupRelay

func SendToBackupRelay(backupURL string, evt nostr.Event) error

func SerializeEvent

func SerializeEvent(evt nostr.Event) string

SerializeEvent manually constructs the JSON string for event serialization according to NIP-01

func ToInt

func ToInt(i interface{}) *int

func ToInt64

func ToInt64(i interface{}) *int64

func ToIntArray

func ToIntArray(i interface{}) []int

func ToStringArray

func ToStringArray(i interface{}) []string

func ToTagsMap

func ToTagsMap(i interface{}) map[string][]string

func ToTime

func ToTime(data interface{}) *time.Time

Types

type CachedDomains

type CachedDomains struct {
	Timestamp int64               `json:"timestamp"` // Store Unix timestamp
	Domains   map[string][]string `json:"domains"`   // Cached pubkeys per domain
}

type NostrJSON

type NostrJSON struct {
	Names map[string]string `json:"names"`
}

Domain types

type RelayMetadata

type RelayMetadata struct {
	Name          string `json:"name"`
	Description   string `json:"description"`
	Pubkey        string `json:"pubkey"`
	Contact       string `json:"contact"`
	SupportedNIPs []int  `json:"supported_nips"`
	Software      string `json:"software"`
	Version       string `json:"version"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL