nostr

package
v0.0.0-...-0269a1e Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NostrID is the ID for state of a nostr client in the connection state.
	NostrID = "nostr"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client exposes nostr related functionality

func NewClient

func NewClient() *Client

NewClient creates a new client

func (*Client) CloseSubscription

func (c *Client) CloseSubscription(ctx context.Context, conState jsonrpc.State, id string) error

CloseSubscription closes a subscription by id

func (*Client) ConnectAuthRelay

func (c *Client) ConnectAuthRelay(ctx context.Context, conState jsonrpc.State, url string) error

ConnectRelay connects to an authenticated relay with a given url

func (*Client) ConnectRelay

func (c *Client) ConnectRelay(ctx context.Context, conState jsonrpc.State, url string) error

ConnectRelay connects to a relay with a given url

func (*Client) CreateChannel

func (c *Client) CreateChannel(ctx context.Context, conState jsonrpc.State, input CreateChannelInput) (string, error)

CreateChannel creates a new channel

func (*Client) CreateChannelMessage

func (c *Client) CreateChannelMessage(ctx context.Context, conState jsonrpc.State, input CreateChannelMessageInput) (string, error)

CreateChannelMessage creates a channel message

func (*Client) GenerateKeyPair

func (c *Client) GenerateKeyPair(ctx context.Context) (string, error)

GenerateKeyPair generates a new keypair

func (*Client) GetChannelMessages

func (c *Client) GetChannelMessages(ctx context.Context, conState jsonrpc.State, input FetchChannelMessageInput) ([]nostr.RelayChannelMessage, error)

GetChannelMessages returns channel messages

func (*Client) GetEvents

func (c *Client) GetEvents(ctx context.Context, conState jsonrpc.State) ([]nostr.NostrEvent, error)

GetEvents returns all events for all subscriptions

func (*Client) GetId

func (c *Client) GetId(ctx context.Context, conState jsonrpc.State) (string, error)

GetPublicKey returns the nostr ID for the client

func (*Client) GetPublicKey

func (c *Client) GetPublicKey(ctx context.Context, conState jsonrpc.State) (string, error)

GetPublicKey returns the public key of the client in hex

func (*Client) GetSubscriptionEvents

func (c *Client) GetSubscriptionEvents(ctx context.Context, conState jsonrpc.State, args GetSubscriptionEventsInput) ([]nostr.NostrEvent, error)

GetSubscriptionEvents returns all events for a subscription with the specified id

func (*Client) GetSubscriptionIds

func (c *Client) GetSubscriptionIds(ctx context.Context, conState jsonrpc.State) ([]string, error)

GetSubscriptionIds returns all subscription ids

func (*Client) ListChannels

func (c *Client) ListChannels(ctx context.Context, conState jsonrpc.State) ([]nostr.RelayChannel, error)

ListChannels on connected relays

func (*Client) Load

func (c *Client) Load(ctx context.Context, conState jsonrpc.State, secret string) error

Load a client from a connection state

func (*Client) PublishDirectMessage

func (c *Client) PublishDirectMessage(ctx context.Context, conState jsonrpc.State, input DirectMessageInput) error

PublishDirectMessage publishes a direct message to a receiver

func (*Client) PublishMetadata

func (c *Client) PublishMetadata(ctx context.Context, conState jsonrpc.State, input MetadataInput) error

PublishMetadata publishes metadata to all relays

func (*Client) PublishProduct

func (c *Client) PublishProduct(ctx context.Context, conState jsonrpc.State, input ProductInput) error

PublishProduct publishes a new product to the relay

func (*Client) PublishStall

func (c *Client) PublishStall(ctx context.Context, conState jsonrpc.State, input StallInput) error

PublishStall publishes a new stall to the relay

func (*Client) PublishTextNote

func (c *Client) PublishTextNote(ctx context.Context, conState jsonrpc.State, input TextInput) error

PublishTextNote publishes a text note to all relays

func (*Client) SubscribeChannelCreation

func (c *Client) SubscribeChannelCreation(ctx context.Context, conState jsonrpc.State) (string, error)

SubscribeChannelCreation subscribes to channel creation events on the relay

func (*Client) SubscribeChannelMessage

func (c *Client) SubscribeChannelMessage(ctx context.Context, conState jsonrpc.State, input SubscribeChannelMessageInput) (string, error)

SubscribeChannelMessage subscribes to a channel messages or message replies, depending on the the id provided

func (*Client) SubscribeDirectMessages

func (c *Client) SubscribeDirectMessages(ctx context.Context, conState jsonrpc.State) (string, error)

SubscribeDirectMessages subscribes to direct messages on all relays and decrypts them

func (*Client) SubscribeProductCreation

func (c *Client) SubscribeProductCreation(ctx context.Context, conState jsonrpc.State) (string, error)

SubscribeProductCreation subscribes to product creation on all relays

func (*Client) SubscribeStallCreation

func (c *Client) SubscribeStallCreation(ctx context.Context, conState jsonrpc.State) (string, error)

SubscribeStallCreation subscribes to stall creation on all relays

func (*Client) SubscribeTextNotes

func (c *Client) SubscribeTextNotes(ctx context.Context, conState jsonrpc.State) (string, error)

SubscribeTextNotes subscribes to text notes on all relays

type CreateChannelInput

type CreateChannelInput struct {
	Tags    []string `json:"tags"`
	Name    string   `json:"name"`
	About   string   `json:"about"`
	Picture string   `json:"picture"`
}

type CreateChannelMessageInput

type CreateChannelMessageInput struct {
	ChannelID string `json:"channel_id"`
	Content   string `json:"content"`
	// MessageID is used for replies
	MessageID string `json:"message_id"`
	// PublicKey of author to reploy to
	PublicKey string `json:"public_key"`
}

type DirectMessageInput

type DirectMessageInput struct {
	Receiver string   `json:"receiver"`
	Tags     []string `json:"tags"`
	Content  string   `json:"content"`
}

type FetchChannelMessageInput

type FetchChannelMessageInput struct {
	ChannelId string `json:"channel_id"`
}

type GetSubscriptionEventsInput

type GetSubscriptionEventsInput struct {
	ID    string `json:"id"`
	Count uint32 `json:"count"`
}

GetSubscriptionEventsInput specifies subscription events retrieval information

type MetadataInput

type MetadataInput struct {
	Tags     []string       `json:"tags"`
	Metadata nostr.Metadata `json:"metadata"`
}

MetadataInput is metadata published on a relay

type NostrState

type NostrState struct {
	Client *nostr.Client
}

state managed by nostr client

func State

func State(conState jsonrpc.State) *NostrState

State from a connection. If no state is present, it is initialized

func (*NostrState) Close

func (s *NostrState) Close()

Close implements jsonrpc.Closer

type ProductInput

type ProductInput struct {
	Tags    []string      `json:"tags"`
	Product nostr.Product `json:"product"`
}

type StallInput

type StallInput struct {
	Tags  []string    `json:"tags"`
	Stall nostr.Stall `json:"stall"`
}

type SubscribeChannelMessageInput

type SubscribeChannelMessageInput struct {
	// ID of the channel or message for which the reply is intended
	ID string `json:"id"`
}

type TextInput

type TextInput struct {
	Tags    []string `json:"tags"`
	Content string   `json:"content"`
}

TextNote is a text note published on a relay

Jump to

Keyboard shortcuts

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