Skip to content

Send a gift wrap signed by custom signer to NIP-17 relays. #783

@reyamir

Description

@reyamir

Describe the enhancement
In my app, I need to send a gift wrap signed by custom signer to user's nip17 relays. But there are no functions allow to do it yet.

I've made a custom function like this in my fork. But I'm not sure about it so I didn't created a PR.

/// Send the gift wrap event to relays
///
/// # Overview
///
/// Send the [`Gift Wrap`] to all relays with [`RelayServiceFlags::WRITE`] flag.
///
/// # Gossip
///
/// If `gossip` is enabled (see [`Options::gossip`]):
/// - the [`Gift Wrap`] will be sent also to NIP17 relays (automatically discovered);
#[inline]
#[cfg(feature = "nip59")]
pub async fn send_gift_wrap(&self, gift_wrap: &Event) -> Result<Output<EventId>, Error> {
    // NOT gossip, send event to all relays
    if !self.opts.gossip {
        return Ok(self.pool.send_event(gift_wrap).await?);
    }

    // Send event using gossip
    self.gossip_send_event(gift_wrap, true).await
}

Use case
Useful for NIP-4E

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions