wire

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Unlicense Imports: 5 Imported by: 0

Documentation

Overview

Package wire defines the Nostr relay wire-protocol packet types (EVENT, REQ, EOSE, OK, NOTICE, CLOSE, AUTH, and NIP-77 negentropy packets) and their JSON encoding. Most consumers should reach for relay/client instead of this package directly — it hides these packet types behind a higher-level Connection API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPacketError

func IsPacketError(err error) bool

Types

type AuthChallengeResponse

type AuthChallengeResponse struct {
	Challenge string
}

func (*AuthChallengeResponse) MarshalJSON

func (acr *AuthChallengeResponse) MarshalJSON() ([]byte, error)

func (*AuthChallengeResponse) UnmarshalJSON added in v0.2.2

func (acr *AuthChallengeResponse) UnmarshalJSON(data []byte) error

type AuthPacket

type AuthPacket struct {
	Event *nip01.Event
}

func (*AuthPacket) MarshalJSON

func (ap *AuthPacket) MarshalJSON() ([]byte, error)

type ClientPayload

type ClientPayload struct {
	SubscriptionResponse
}

func (*ClientPayload) UnmarshalJSON

func (sr *ClientPayload) UnmarshalJSON(data []byte) error

type ClosePacket

type ClosePacket struct {
	SubscriptionID string
}

func NewClosePacket

func NewClosePacket(subID string) *ClosePacket

func (*ClosePacket) MarshalJSON

func (rp *ClosePacket) MarshalJSON() ([]byte, error)

func (*ClosePacket) String

func (cp *ClosePacket) String() string

type ClosedSubscriptionResponse

type ClosedSubscriptionResponse struct {
	SubscriptionID string
	Message        string
}

func (*ClosedSubscriptionResponse) MarshalJSON

func (csr *ClosedSubscriptionResponse) MarshalJSON() ([]byte, error)

func (*ClosedSubscriptionResponse) UnmarshalJSON

func (csr *ClosedSubscriptionResponse) UnmarshalJSON(data []byte) error

type CountPacket

type CountPacket struct {
	SubscriptionID string
	Filters        *nip01.SubscriptionFilterGroup
}

func (*CountPacket) MarshalJSON

func (cp *CountPacket) MarshalJSON() ([]byte, error)

type CountSubscriptionResponse

type CountSubscriptionResponse struct {
	SubscriptionID string
	Count          int64
}

func (*CountSubscriptionResponse) MarshalJSON

func (csr *CountSubscriptionResponse) MarshalJSON() ([]byte, error)

func (*CountSubscriptionResponse) UnmarshalJSON added in v0.2.2

func (csr *CountSubscriptionResponse) UnmarshalJSON(data []byte) error

type EOSESubscriptionResponse

type EOSESubscriptionResponse struct {
	SubscriptionID string
}

func (*EOSESubscriptionResponse) MarshalJSON

func (esr *EOSESubscriptionResponse) MarshalJSON() ([]byte, error)

func (*EOSESubscriptionResponse) UnmarshalJSON

func (esr *EOSESubscriptionResponse) UnmarshalJSON(data []byte) error

type EventPacket

type EventPacket struct {
	Event *nip01.Event
}

func NewEventPacket

func NewEventPacket(ev *nip01.Event) *EventPacket

func (*EventPacket) MarshalJSON

func (ep *EventPacket) MarshalJSON() ([]byte, error)

func (*EventPacket) String

func (ep *EventPacket) String() string

type EventSubscriptionResponse

type EventSubscriptionResponse struct {
	SubscriptionID string
	Event          *nip01.Event
	// For sending raw bytes if available (optimization)
	EventBytes []byte
}

func (*EventSubscriptionResponse) MarshalJSON

func (esr *EventSubscriptionResponse) MarshalJSON() ([]byte, error)

func (*EventSubscriptionResponse) UnmarshalJSON

func (esr *EventSubscriptionResponse) UnmarshalJSON(data []byte) error

type NegClosePacket

type NegClosePacket struct {
	SubscriptionID string
}

func (*NegClosePacket) MarshalJSON

func (p *NegClosePacket) MarshalJSON() ([]byte, error)

type NegErrPacket

type NegErrPacket struct {
	SubscriptionID string
	Code           string
}

func (*NegErrPacket) MarshalJSON

func (p *NegErrPacket) MarshalJSON() ([]byte, error)

type NegErrResponse

type NegErrResponse struct {
	SubscriptionID string
	Code           string
}

func (*NegErrResponse) MarshalJSON

func (r *NegErrResponse) MarshalJSON() ([]byte, error)

func (*NegErrResponse) UnmarshalJSON

func (r *NegErrResponse) UnmarshalJSON(data []byte) error

type NegMsgPacket

type NegMsgPacket struct {
	SubscriptionID string
	Message        string
}

func (*NegMsgPacket) MarshalJSON

func (p *NegMsgPacket) MarshalJSON() ([]byte, error)

type NegMsgResponse

type NegMsgResponse struct {
	SubscriptionID string
	Message        string
}

func (*NegMsgResponse) MarshalJSON

func (r *NegMsgResponse) MarshalJSON() ([]byte, error)

func (*NegMsgResponse) UnmarshalJSON

func (r *NegMsgResponse) UnmarshalJSON(data []byte) error

type NegOpenPacket

type NegOpenPacket struct {
	SubscriptionID string
	Filter         *nip01.SubscriptionFilter
	Message        string
}

func (*NegOpenPacket) MarshalJSON

func (p *NegOpenPacket) MarshalJSON() ([]byte, error)

type NoticeSubscriptionResponse

type NoticeSubscriptionResponse struct {
	Message string
}

func (*NoticeSubscriptionResponse) MarshalJSON

func (nsr *NoticeSubscriptionResponse) MarshalJSON() ([]byte, error)

func (*NoticeSubscriptionResponse) UnmarshalJSON

func (nsr *NoticeSubscriptionResponse) UnmarshalJSON(data []byte) error

type OkSubscriptionResponse

type OkSubscriptionResponse struct {
	EventID  string
	Accepted bool
	Message  string
}

func (*OkSubscriptionResponse) MarshalJSON

func (osr *OkSubscriptionResponse) MarshalJSON() ([]byte, error)

func (*OkSubscriptionResponse) UnmarshalJSON

func (osr *OkSubscriptionResponse) UnmarshalJSON(data []byte) error

type Packet

type Packet interface {
}

type PacketError

type PacketError struct {
	Message string
	Origin  error
}

func NewPacketError

func NewPacketError(message string, err error, args ...interface{}) *PacketError

func (*PacketError) Error

func (pe *PacketError) Error() string

type RelayPayload

type RelayPayload struct {
	Packet Packet
}

func (*RelayPayload) UnmarshalJSON

func (p *RelayPayload) UnmarshalJSON(data []byte) error

type RequestPacket

type RequestPacket struct {
	SubscriptionID string
	Filters        *nip01.SubscriptionFilterGroup
}

func NewRequestPacket

func NewRequestPacket(subID string, filters *nip01.SubscriptionFilterGroup) *RequestPacket

func (*RequestPacket) MarshalJSON

func (rp *RequestPacket) MarshalJSON() ([]byte, error)

func (*RequestPacket) String

func (rp *RequestPacket) String() string

type SubscriptionResponse

type SubscriptionResponse interface{}

Jump to

Keyboard shortcuts

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