Crate nostr_types

Source
Expand description

This crate provides types for nostr protocol handling.

Modules§

client
A basic nostr client
nip46
NIP-46 nsec bunker related types and functions

Structs§

CountResult
The count results
DelegationConditions
Conditions of delegation
EncryptedPrivateKey
This is an encrypted private key (the string inside is the bech32 ncryptsec string)
EventKindIterator
Iterator over well known EventKinds
EventV3
The main event type
FeeV1
Fee
FileMetadata
NIP-92/94 File Metadata
FilterV1
Filter which specify what events a client is looking for
FilterV2
Filter which specify what events a client is looking for
Hll8
HyperLogLog approximate counting mechanism
Id
An event identifier, constructed as a SHA256 hash of the event fields according to NIP-01
IdHex
An event identifier, constructed as a SHA256 hash of the event fields according to NIP-01, as a hex string
KeySigner
Signer with a local private key (and public key)
MetadataV1
Metadata about a user
MetadataV2
Metadata about a user
MilliSatoshi
Bitcoin amount measured in millisatoshi
NAddr
An ‘naddr’: data to address a possibly parameterized replaceable event (d-tag, kind, author, and relays)
NEvent
An ‘nevent’: event id along with some relays in which that event may be found.
Nip05V1
The content of a webserver’s /.well-known/nostr.json file used in NIP-05 and NIP-35 This allows lookup and verification of a nostr user via a user@domain style identifier.
NostrUrl
A Nostr URL (starting with ‘nostr:’)
PayRequestData
This is a response from a zapper lnurl
PreEventV3
Data used to construct an event
PrivateKey
This is a private key which is to be kept secret and is used to prove identity
Profile
A person’s profile on nostr which consists of the data needed in order to follow someone.
PublicKey
This is a public key, which identifies an actor (usually a person) and is shared.
PublicKeyHex
This is a public key, which identifies an actor (usually a person) and is shared, as a hex string
RelayFeesV1
Relay fees
RelayInformationDocumentV1
Relay information document as described in NIP-11, supplied by a relay
RelayInformationDocumentV2
Relay information document as described in NIP-11, supplied by a relay
RelayLimitationV1
Relay limitations
RelayLimitationV2
Relay limitations
RelayList
A relay list, indicating usage for each relay, which can be used to represent the data found in a kind 10002 RelayListMetadata event.
RelayOrigin
A canonical URL representing just a relay’s origin (without path/query/fragment or username/password)
RelayRetentionV1
Relay retention
RelayUrl
A Url validated as a nostr relay url in canonical form We don’t serialize/deserialize these directly, see UncheckedUrl for that
RelayUsageSet
The ways that a user uses a Relay
RumorV3
A Rumor is an Event without a signature
ShatteredContent
A sequence of content segments
Signature
A Schnorr signature that signs an Event, taken on the Event Id field
SignatureHex
A Schnorr signature that signs an Event, taken on the Event Id field, as a hex string
SimpleRelayList
A list of relays with SimpleRelayUsage
SimpleRelayUsage
When and how to use a Relay
Span
This is like Range<usize>, except we impl offset() on it This is like linkify::Span, except we impl offset() on it and don’t need the as_str() or kind() functions.
SubscriptionId
A random client-chosen string used to refer to a subscription
TagV3
A tag on an Event
UncheckedUrl
A string that is supposed to represent a URL but which might be invalid
Unixtime
An integer count of the number of seconds from 1st January 1970. This does not count any of the leap seconds that have occurred, it simply presumes UTC never had leap seconds; yet it is well known and well understood.
Url
A String representing a valid URL with an authority present including an Internet based host.
XOnlyPublicKey
An x-only public key, used for verification of Taproot signatures and serialized according to BIP-340.
ZapDataV1
Data about a Zap
ZapDataV2
Data about a Zap

Enums§

ClientMessage
A message from a client to a relay
ContentEncryptionAlgorithm
Content Encryption Algorithm
ContentSegment
A segment of content
Error
Errors that can occur in the nostr-proto crate
EventDelegation
Delegation information for an Event
EventKind
A kind of Event
EventKindOrRange
Either an EventKind or a range (a vector of length 2 with start and end)
EventReference
A reference to another event, either by Id (often coming from an ‘e’ tag), or by NAddr (often coming from an ‘a’ tag).
Identity
All states that your identity can be in
KeySecurity
This indicates the security of the key by keeping track of whether the secret key material was handled carefully. If the secret is exposed in any way, or leaked and the memory not zeroed, the key security drops to Weak.
NostrBech32
A bech32 sequence representing a nostr object (or set of objects)
ParsedTag
This parses known simple tags in a uniform way.
RelayListUsage
Relay Usage
RelayMessage
A message from a relay to a client
RelayUsage
A way that a user uses a Relay
Why
The reason why a relay issued an OK or CLOSED message

Traits§

ExportableSigner
Any Signer that allows the secret to be exported (with interior mutability or no mutability necessary)
LockableSigner
Any Signer that can be locked and unlocked with a passphrase
MutExportableSigner
Any Signer that allows the secret to be exported, but requires Self to be mutable to do so.
Signer
Signer operations
SignerExt
Extended Signer operations

Functions§

add_addr_to_tags
Add an ‘a’ addr tag to a set of tags if it doesn’t already exist
add_event_to_tags
Add an ‘e’ id tag to a set of tags if it doesn’t already exist
add_pubkey_to_tags
Add a ‘p’ pubkey tag to a set of tags if it doesn’t already exist
add_subject_to_tags_if_missing
Add an ‘subject’ tag to a set of tags if it doesn’t already exist
find_nostr_bech32_pos
Returns start and end position of next valid NostrBech32
find_nostr_url_pos
Returns start and end position of next valid NostrUrl

Type Aliases§

Event
The main event type
Fee
Fee
Filter
The main filter type
Metadata
Metadata about a user
Nip05
The content of a webserver’s /.well-known/nostr.json file used in NIP-05 and NIP-35 This allows lookup and verification of a nostr user via a user@domain style identifier.
PreEvent
Data used to construct an event
RelayFees
Relay fees
RelayInformationDocument
Relay information document as described in NIP-11, supplied by a relay
RelayLimitation
Relay limitations
RelayRetention
Relay retention
Rumor
A Rumor is an Event without a signature
Tag
A tag on an Event
ZapData
Data about a Zap