event

package
v1.2.37 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(in by) (out by)

Types

type Ascending

type Ascending []*T

Ascending is a slice of events that sorts in ascending chronological order

func (Ascending) Len

func (ev Ascending) Len() no

func (Ascending) Less

func (ev Ascending) Less(i, j no) bo

func (Ascending) Swap

func (ev Ascending) Swap(i, j no)

type C

type C chan *T

type Descending

type Descending []*T

Descending sorts a slice of events in reverse chronological order (newest first)

func (Descending) Len

func (e Descending) Len() no

func (Descending) Less

func (e Descending) Less(i, j no) bo

func (Descending) Swap

func (e Descending) Swap(i, j no)

type T

type T struct {
	// ID is the SHA256 hash of the canonical encoding of the event in binary format
	ID by
	// PubKey is the public key of the event creator in binary format
	PubKey by
	// CreatedAt is the UNIX timestamp of the event according to the event
	// creator (never trust a timestamp!)
	CreatedAt *timestamp.T
	// Kind is the nostr protocol code for the type of event. See kind.T
	Kind *kind.T
	// Tags are a list of tags, which are a list of strings usually structured
	// as a 3 layer scheme indicating specific features of an event.
	Tags *tags.T
	// Content is an arbitrary string that can contain anything, but usually
	// conforming to a specification relating to the Kind and the Tags.
	Content by
	// Sig is the signature on the ID hash that validates as coming from the
	// Pubkey in binary format.
	Sig by
}

T is the primary datatype of nostr. This is the form of the structure that defines its JSON string based format.

func GenerateRandomTextNoteEvent

func GenerateRandomTextNoteEvent(sign signer.I, maxSize no) (ev *T,
	err er)

func New

func New() (ev *T)

func (*T) CheckSignature deprecated

func (ev *T) CheckSignature() (valid bo, err er)

CheckSignature returns whether an event signature is authentic and matches the event ID and Pubkey.

Deprecated: use Verify

func (*T) ContentString

func (ev *T) ContentString() (s st)

func (*T) EventID

func (ev *T) EventID() (eid *eventid.T)

func (*T) GetIDBytes

func (ev *T) GetIDBytes() by

GetIDBytes returns the raw SHA256 hash of the canonical form of an T.

func (*T) IDString

func (ev *T) IDString() (s st)

func (*T) MarshalJSON

func (ev *T) MarshalJSON(dst by) (b by, err er)

func (*T) PubKeyString

func (ev *T) PubKeyString() (s st)

func (*T) Serialize

func (ev *T) Serialize() (b by)

func (*T) SigString

func (ev *T) SigString() (s st)

func (*T) Sign

func (ev *T) Sign(keys signer.I) (err er)

Sign the event using the signer.I. Uses github.com/bitcoin-core/secp256k1 if available for much faster signatures.

func (*T) SignWithSecKey deprecated

func (ev *T) SignWithSecKey(sk *k1.SecretKey,
	so ...sch.SignOption) (err er)

SignWithSecKey signs an event with a given *secp256xk1.SecretKey.

Deprecated: use Sign and nostr.I and p256k.Signer / p256k.BTCECSigner implementations.

func (*T) TagStrings

func (ev *T) TagStrings() (s [][]st)

func (*T) ToCanonical

func (ev *T) ToCanonical() (b by)

func (*T) UnmarshalJSON

func (ev *T) UnmarshalJSON(b by) (r by, err er)

func (*T) Verify

func (ev *T) Verify() (valid bo, err er)

Verify an event is signed by the pubkey it contains. Uses github.com/bitcoin-core/secp256k1 if available for faster verification.

type Ts

type Ts []*T

Ts is an array of T that sorts in reverse chronological order.

func (Ts) Len

func (ev Ts) Len() no

func (Ts) Less

func (ev Ts) Less(i, j no) bo

func (Ts) Swap

func (ev Ts) Swap(i, j no)

Directories

Path Synopsis
codectester

Jump to

Keyboard shortcuts

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