Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateKeyPair() string
- type Channel
- type ChannelMessage
- type Client
- func (c *Client) CloseSubscription(id string)
- func (c *Client) ConnectAuthRelay(ctx context.Context, relayURL string) error
- func (c *Client) ConnectRelay(ctx context.Context, relayURL string) error
- func (c *Client) CreateChannel(ctx context.Context, tags []string, content Channel) (string, error)
- func (c *Client) CreateChannelRootMessage(ctx context.Context, message ChannelMessage) (string, error)
- func (c *Client) FetchChannelCreation() ([]RelayChannel, error)
- func (c *Client) FetchChannelMessages(channelID string) ([]RelayChannelMessage, error)
- func (c *Client) GetEvents() []NostrEvent
- func (c *Client) GetSubscriptionEvents(id string) []NostrEvent
- func (c *Client) GetSubscriptionEventsWithCount(id string, count uint32) []NostrEvent
- func (c *Client) HideMessage(ctx context.Context, tags []string, messageID string, content string) error
- func (c *Client) Id() string
- func (c *Client) MuteUser(ctx context.Context, tags []string, user string, content string) error
- func (c *Client) PublicKey() string
- func (c *Client) PublishDirectMessage(ctx context.Context, receiver string, tags []string, content string) error
- func (c *Client) PublishEventDeletion(ctx context.Context, tags []string, id string) error
- func (c *Client) PublishMetadata(ctx context.Context, tags []string, content Metadata) error
- func (c *Client) PublishProduct(ctx context.Context, tags []string, content Product) error
- func (c *Client) PublishRecommendServer(ctx context.Context, tags []string, content string) error
- func (c *Client) PublishStall(ctx context.Context, tags []string, content Stall) error
- func (c *Client) PublishTextNote(ctx context.Context, tags []string, content string) error
- func (c *Client) SubscribeChannelCreation() (string, error)
- func (c *Client) SubscribeChannelMessages(id string) (string, error)
- func (c *Client) SubscribeDirectMessagesDirect(swapTag string) (<-chan NostrEvent, error)
- func (c *Client) SubscribeMessages() (string, error)
- func (c *Client) SubscribeProductCreation(tag string) (string, error)
- func (c *Client) SubscribeStallCreation(tag string) (string, error)
- func (c *Client) SubscribeTextNotes() (string, error)
- func (c *Client) SubscriptionIds() []string
- func (c *Client) UpdateChannelMetadata(ctx context.Context, tags []string, channelID string, content Channel) error
- type Metadata
- type NostrEvent
- type Product
- type RelayChannel
- type RelayChannelMessage
- type RelayEvent
- type Server
- type Shipping
- type Stall
- type Subscription
Constants ¶
const ( // size of a subscription id SUB_ID_LENGTH = 10 DEFAULT_LIMIT = 100 )
const BUFFER_SIZE = 1000
Size of the buffer
Variables ¶
var ( // ErrRelayAuthFailed indicates the authentication on a relay completed, but failed ErrRelayAuthFailed = errors.New("failed to authenticate to the relay") // ErrRelayAuthTimeout indicates the authentication on a relay did not complete in time ErrRelayAuthTimeout = errors.New("timeout authenticating to the relay") // ErrFailedToPublishEvent indicates the event could not be published to the relay ErrFailedToPublishEvent = errors.New("failed to publish event to relay") /// ErrNoRelayConnected inidcates that we try to perform an action on a realay, but we aren't connected to any. ErrNoRelayConnected = errors.New("no relay connected currently") )
var ( // TagTftAtomicSwapSale is the searchable tag for atomic swaps in tft TagTftAtomicSwapSale = []string{"t", "tft_atomic_swap_sale_order"} )
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair() string
Types ¶
type ChannelMessage ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for nostr protocol
func (*Client) CloseSubscription ¶
CloseSubscription managed by the server for this client, based on its ID.
func (*Client) ConnectAuthRelay ¶
ConnectAuthRelay connect and authenticates to a NIP42 authenticated relay
func (*Client) ConnectRelay ¶
func (*Client) CreateChannel ¶
CreateChannel creates a new channel
func (*Client) CreateChannelRootMessage ¶
func (c *Client) CreateChannelRootMessage(ctx context.Context, message ChannelMessage) (string, error)
CreateChannelRootMessage creates a message in channel. If replyTo is the empty string, it is marked as a root
func (*Client) FetchChannelCreation ¶
func (c *Client) FetchChannelCreation() ([]RelayChannel, error)
FetchChannelCreation fetches and returns channel creation events
func (*Client) FetchChannelMessages ¶
func (c *Client) FetchChannelMessages(channelID string) ([]RelayChannelMessage, error)
SubscribeChannelMessages subsribes to messages which are a reply to the given chanMessageId
func (*Client) GetEvents ¶
func (c *Client) GetEvents() []NostrEvent
Get all historic events on active subscriptions for the client. Note that only a limited amount of events are kept. If the actual client waits too long to call this, events might be dropped. returned events are sorted from oldes to newest
func (*Client) GetSubscriptionEvents ¶
func (c *Client) GetSubscriptionEvents(id string) []NostrEvent
GetSubscriptionEvents for a subscription with the given ID. Events are removed from the subscription
func (*Client) GetSubscriptionEventsWithCount ¶
func (c *Client) GetSubscriptionEventsWithCount(id string, count uint32) []NostrEvent
GetSubscriptionEventsWithCount returns a number of events for a subscription with the given ID. Returned events are removed from the subscription
func (*Client) HideMessage ¶
func (c *Client) HideMessage(ctx context.Context, tags []string, messageID string, content string) error
HideMessage marks a message as hidden for the user. It should be noted that properly handling this is mostly up to the clients
func (*Client) MuteUser ¶
MuteUser marks a user as muted for the current user. It should be noted that properly handling this is mostly up to the clients. The user to mute is identified by it's pubkey
func (*Client) PublishDirectMessage ¶
func (c *Client) PublishDirectMessage(ctx context.Context, receiver string, tags []string, content string) error
/ PublishDirectMessage publishes a direct message for a given peer identified by the given pubkey on the connected relays
func (*Client) PublishEventDeletion ¶
PublishEventDeletion to connected relays. If an event with the given ID was already published, conforming relays should delete it
func (*Client) PublishMetadata ¶
PublishMetadata to connected relays. If metadata was published previously, the old metadata should be overwritten conforming relays
func (*Client) PublishProduct ¶
PublishProduct to connected relays. If a product with the given ID was already published, conforming relays should update it
func (*Client) PublishRecommendServer ¶
PublishRecommendServer to connected relays. The content is supposed to be the URL of the relay being recommended
func (*Client) PublishStall ¶
PublishStall to connected relays. If a stall with the given ID was already published, conforming relays should update it
func (*Client) PublishTextNote ¶
PublishTextNote to connected relays
func (*Client) SubscribeChannelCreation ¶
func (*Client) SubscribeChannelMessages ¶
SubscribeChannelMessages subsribes to a messages sent to a channel with id `id`, or reply messages to the message with id `id`
func (*Client) SubscribeDirectMessagesDirect ¶
func (c *Client) SubscribeDirectMessagesDirect(swapTag string) (<-chan NostrEvent, error)
TODO: Remove once subsciptions are more porper
func (*Client) SubscribeMessages ¶
SubscribeMessages subscribes to direct messages (Kind 4) on all relays and decrypts them if they are addressed to the client
func (*Client) SubscribeProductCreation ¶
Subscribe ProductCreation subscribes to product creation events (Kind 30018) on all relays
func (*Client) SubscribeStallCreation ¶
SubscribeStallCreation subscribes to stall creation events (Kind 30017) on all relays
func (*Client) SubscribeTextNotes ¶
SubscribeTextNotes to textnote events on a relay
func (*Client) SubscriptionIds ¶
Get the ID's of all active subscriptions
type Metadata ¶
type Metadata struct { Name string `json:"name"` About string `json:"about"` Picture string `json:"picture"` }
Metadata used when setting metadata, see [nip01](https://github.com/nostr-protocol/nips/blob/master/01.md)
type NostrEvent ¶
type NostrEvent = nostr.Event
type Product ¶
type Product struct { Id string `json:"id"` StallId string `json:"stall_id"` Name string `json:"name"` Description string `json:"description,omitempty"` Images []string `json:"images,omitempty"` Currency string `json:"currency"` Price float64 `json:"price"` Quantity uint `json:"quantity"` // Specs is an array of key value pairs Specs [][]string `json:"specs"` }
Product for sale in a stall
type RelayChannel ¶
type RelayChannelMessage ¶
type RelayEvent ¶
type RelayEvent struct { Relay string `json:"relay"` Event NostrEvent `json:"event"` }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a persistent client keeping open connections to relays.
type Shipping ¶
type Shipping struct { Id string `json:"id"` Name string `json:"name,omitempty"` Cost float64 `json:"cost"` Countries []string `json:"countries"` }
Shipping information for a Stall
type Stall ¶
type Stall struct { Id string `json:"id"` Name string `json:"name"` Description string `json:"description,omitempty"` Currency string `json:"currency"` Shipping []Shipping `json:"shipping"` }
Stall of products for sale
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription for events on a relay