Skip to content

Commit

Permalink
Make nostr-sdk signing events public
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 24, 2024
1 parent 6769640 commit ff57df6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ impl Client {
Ok(self.pool.send_event_to(url, event, opts).await?)
}

async fn internal_sign_event_builder(&self, builder: EventBuilder) -> Result<Event, Error> {
/// Signs the [`EventBuilder`] into an [`Event`] using the [`ClientSigner`]
pub async fn sign_event_builder(&self, builder: EventBuilder) -> Result<Event, Error> {
match self.signer().await? {
ClientSigner::Keys(keys) => {
let difficulty: u8 = self.opts.get_difficulty();
Expand Down Expand Up @@ -770,7 +771,7 @@ impl Client {
///
/// Rise an error if the [`ClientSigner`] is not set.
pub async fn send_event_builder(&self, builder: EventBuilder) -> Result<EventId, Error> {
let event: Event = self.internal_sign_event_builder(builder).await?;
let event: Event = self.sign_event_builder(builder).await?;
self.send_event(event).await
}

Expand All @@ -786,7 +787,7 @@ impl Client {
U: TryIntoUrl,
pool::Error: From<<U as TryIntoUrl>::Err>,
{
let event: Event = self.internal_sign_event_builder(builder).await?;
let event: Event = self.sign_event_builder(builder).await?;
self.send_event_to(url, event).await
}

Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/src/client/zapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl Client {
match details.r#type {
ZapType::Public => {
let builder = EventBuilder::public_zap_request(data);
Some(self.internal_sign_event_builder(builder).await?.as_json())
Some(self.sign_event_builder(builder).await?.as_json())
}
ZapType::Private => None,
ZapType::Anonymous => Some(nip57::anonymous_zap_request(data)?.as_json()),
Expand Down

0 comments on commit ff57df6

Please sign in to comment.