Skip to main content

Module inbox_relays

Module inbox_relays 

Source
Expand description

NIP-17 Kind 10050 (DM Relay List) support.

Fetches, caches, and publishes kind 10050 events so that DM gift wraps are delivered to the recipient’s preferred inbox relays.

Structs§

EventPublishTracker
Per-relay publish tracker. One per outbound event whose dependents (deletions, edits, reactions, replies, …) need to fire only after the parent has actually landed at each individual relay.
GiftWrapSendOutcome
Outcome of a retained-key gift-wrap send. Caller is expected to persist wrap_event_id, wrap_secret, and targeted_relays for future deletion.

Functions§

clear_inbox_relay_cache
Drop every cached recipient relay list — called by reset_session(). The cache is recipient-keyed (so technically account-agnostic) but grows unboundedly across sessions; the 1-hour TTL only reclaims re-queried entries. Clear on swap to free memory and avoid stale-data revivals.
get_publish_tracker
Look up the tracker for an event currently being published. Returns None if the publish has fully settled (all relays done) or if the tracker never existed (e.g. the event was sent in a previous app session, or via a non-tracked send path). Dependent senders fall back to a best-effort broadcast in that case.
publish_inbox_relays
Publish our own kind 10050 event advertising readable relays as DM inboxes. Write-only relays are excluded since senders need to write to them. If no readable relays exist, publishes an empty 10050 to clear any stale list.
republish_inbox_relays_debounced
Republish kind 10050 in the background (debounced). Called after relay config changes (add/remove/toggle/mode update). Rapid successive calls coalesce into a single publish.
send_event_first_ok
Send an event to specific relays, returning as soon as the first relay acknowledges success. Remaining relays continue sending in the background.
send_event_pool_first_ok
Send an event to all write-relays in the pool, returning as soon as the first relay acknowledges success.
send_gift_wrap
Send a gift-wrapped rumor to a recipient, routing to their inbox relays (kind 10050) when available. Falls back to pool broadcast if no inbox relays are found or if targeted delivery fails entirely.
send_gift_wrap_retained
Send a gift-wrapped rumor to a recipient using a retained ephemeral key. Routes to the recipient’s inbox relays (kind 10050) when available, falling back to pool write-relays otherwise.
spawn_tracked_publish
Spawn one publish task per resolved relay and register a tracker keyed by the event id. Returns the join handles so the caller can race them for first-ok or wait for all to settle as needed. The spawned tasks continue updating the tracker after the caller stops waiting on the handles.
trusted_relay_urls
Get the cached parsed trusted relay URLs.
wrap_with_retained_key
Build a NIP-59 kind-1059 gift wrap from a sealed event, returning both the signed wrap event and the ephemeral secp256k1 secret used to sign it.