Documentation
¶
Index ¶
- func Hash(in []byte) (out []byte)
- func Marshal(ev *T, dst []byte) (b []byte)
- func NewCanonical() (a *json.Array)
- func Unmarshal(ev *T, b []byte) (r []byte, err error)
- type Ascending
- type C
- type Descending
- type T
- func (ev *T) CheckSignature() (valid bool, err error)deprecated
- func (ev *T) ContentString() (s string)
- func (ev *T) EventID() (eid *eventid.T)
- func (ev *T) FromCanonical(b []byte) (rem []byte, err error)
- func (ev *T) GetIDBytes() []byte
- func (ev *T) IDString() (s string)
- func (ev *T) Marshal(dst []byte) (b []byte)
- func (ev *T) MarshalCompact(dst []byte) (b []byte)
- func (ev *T) PubKeyString() (s string)
- func (ev *T) Serialize() (b []byte)
- func (ev *T) SerializeIndented() (b []byte)
- func (ev *T) SigString() (s string)
- func (ev *T) Sign(keys signer.I) (err error)
- func (ev *T) SignWithSecKey(sk *k1.SecretKey, so ...sch.SignOption) (err error)deprecated
- func (ev *T) TagStrings() (s [][]string)
- func (ev *T) ToCanonical(dst []byte) (b []byte)
- func (ev *T) Unmarshal(b []byte) (r []byte, err error)
- func (ev *T) UnmarshalCompact(b []byte) (rem []byte, err error)
- func (ev *T) Verify() (valid bool, err error)
- type Ts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCanonical ¶
Types ¶
type Ascending ¶
type Ascending []*T
Ascending is a slice of events that sorts in ascending chronological order
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 T ¶
type T struct { // ID is the SHA256 hash of the canonical encoding of the event in binary format ID []byte // PubKey is the public key of the event creator in binary format PubKey []byte // 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 []byte // Sig is the signature on the ID hash that validates as coming from the // Pubkey in binary format. Sig []byte }
T is the primary datatype of nostr. This is the form of the structure that defines its JSON string based format.
func (*T) CheckSignature
deprecated
func (*T) ContentString ¶
func (*T) FromCanonical ¶
FromCanonical reverses the process of creating the canonical encoding, note that the signature is missing in this form. Allocate an event.T before calling this.
func (*T) GetIDBytes ¶
GetIDBytes returns the raw SHA256 hash of the canonical form of an T.
func (*T) MarshalCompact ¶
MarshalCompact encodes an event as the canonical form followed by the raw binary signature (64 bytes) which hashes to form the ID, thus a compact form for the database that is smaller and fast to decode.
func (*T) PubKeyString ¶
func (*T) SerializeIndented ¶ added in v1.7.14
func (*T) Sign ¶
Sign the event using the signer.I. Uses github.com/bitcoin-core/secp256k1 if available for much faster signatures.
func (*T) SignWithSecKey
deprecated
func (*T) TagStrings ¶
func (*T) ToCanonical ¶
ToCanonical converts the event to the canonical encoding used to derive the event ID.