event

package
v1.2.21 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 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 []byte) (out []byte)

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() int

func (Ascending) Less

func (ev Ascending) Less(i, j int) bool

func (Ascending) Swap

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

type B

type B = []byte

type C

type C chan *T

type Ctx

type Ctx = context.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() int

func (Descending) Less

func (e Descending) Less(i, j int) bool

func (Descending) Swap

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

type E

type E = error

type N

type N = int

type S

type S = string

type T

type T struct {
	// ID is the SHA256 hash of the canonical encoding of the event in binary format
	ID B
	// PubKey is the public key of the event creator in binary format
	PubKey B
	// 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 B
	// Sig is the signature on the ID hash that validates as coming from the
	// Pubkey in binary format.
	Sig B
}

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 int) (ev *T,
	err error)

func New

func New() (ev *T)

func (*T) CheckSignature deprecated

func (ev *T) CheckSignature() (valid bool, err error)

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 S)

func (*T) EventID

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

func (*T) GetIDBytes

func (ev *T) GetIDBytes() []byte

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

func (*T) IDString

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

func (*T) MarshalJSON

func (ev *T) MarshalJSON(dst B) (b B, err error)

func (*T) PubKeyString

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

func (*T) Serialize

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

func (*T) SigString

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

func (*T) Sign

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

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 error)

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 [][]S)

func (*T) ToCanonical

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

func (*T) UnmarshalJSON

func (ev *T) UnmarshalJSON(b B) (r B, err error)

func (*T) Verify

func (ev *T) Verify() (valid bool, err error)

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() int

func (Ts) Less

func (ev Ts) Less(i, j int) bool

func (Ts) Swap

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

Directories

Path Synopsis
codectester

Jump to

Keyboard shortcuts

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