Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit d6e0aa9

Browse files
committed
Update rust-nostr to v0.26
1 parent 10e519d commit d6e0aa9

File tree

9 files changed

+212
-92
lines changed

9 files changed

+212
-92
lines changed

Cargo.lock

Lines changed: 107 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mutiny-core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ futures-util = { version = "0.3", default-features = false }
3838
reqwest = { version = "0.11", default-features = false, features = ["json"] }
3939
async-trait = "0.1.68"
4040
url = { version = "2.3.1", features = ["serde"] }
41-
nostr = { version = "0.24.0", default-features = false, features = ["nip47"] }
42-
nostr-sdk = { version = "0.24.0", default-features = false }
41+
nostr = { version = "0.26.0", default-features = false, features = ["nip47"] }
42+
nostr-sdk = { version = "0.26.0", default-features = false }
4343
cbc = { version = "0.1", features = ["alloc"] }
4444
aes = { version = "0.8" }
4545
jwt-compact = { version = "0.8.0-beta.1", features = ["es256k"] }

mutiny-core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use crate::{
6767
use crate::{nodemanager::NodeManager, nostr::ProfileType};
6868
use crate::{nostr::NostrManager, utils::sleep};
6969
use ::nostr::key::XOnlyPublicKey;
70-
use ::nostr::{Event, Kind, Metadata};
70+
use ::nostr::{Event, JsonUtil, Kind, Metadata};
7171
use bdk_chain::ConfirmationTime;
7272
use bip39::Mnemonic;
7373
use bitcoin::util::bip32::ExtendedPrivKey;
@@ -519,7 +519,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
519519
select! {
520520
notification = read_fut => {
521521
match notification {
522-
Ok(RelayPoolNotification::Event(_url, event)) => {
522+
Ok(RelayPoolNotification::Event { event, .. }) => {
523523
if event.kind == Kind::WalletConnectRequest && event.verify().is_ok() {
524524
match nostr.handle_nwc_request(event, &self_clone).await {
525525
Ok(Some(event)) => {
@@ -534,7 +534,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
534534
}
535535
}
536536
},
537-
Ok(RelayPoolNotification::Message(_, _)) => {}, // ignore messages
537+
Ok(RelayPoolNotification::Message { .. }) => {}, // ignore messages
538538
Ok(RelayPoolNotification::Shutdown) => break, // if we disconnect, we restart to reconnect
539539
Ok(RelayPoolNotification::Stop) => {}, // Currently unused
540540
Ok(RelayPoolNotification::RelayStatus { .. }) => {}, // Currently unused

mutiny-core/src/nodemanager.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use lightning_transaction_sync::EsploraSyncClient;
5050
use lnurl::lnurl::LnUrl;
5151
use lnurl::{AsyncClient as LnUrlClient, LnUrlResponse, Response};
5252
use nostr::key::XOnlyPublicKey;
53-
use nostr::{EventBuilder, Keys, Kind, Tag, TagKind};
53+
use nostr::{EventBuilder, JsonUtil, Keys, Kind, Tag, TagKind};
5454
use payjoin::{PjUri, PjUriExt};
5555
use reqwest::Client;
5656
use serde::{Deserialize, Serialize};
@@ -1694,13 +1694,20 @@ impl<S: MutinyStorage> NodeManager<S> {
16941694
let zap_request = match zap_npub {
16951695
Some(zap_npub) => {
16961696
let tags = vec![
1697-
Tag::PubKey(zap_npub, None),
1698-
Tag::Amount(msats),
1697+
Tag::PublicKey {
1698+
public_key: zap_npub,
1699+
relay_url: None,
1700+
alias: None,
1701+
},
1702+
Tag::Amount {
1703+
millisats: msats,
1704+
bolt11: None,
1705+
},
16991706
Tag::Lnurl(lnurl.to_string()),
17001707
Tag::Relays(vec!["wss://nostr.mutinywallet.com".into()]),
17011708
Tag::Generic(TagKind::Custom("anon".to_string()), vec![]),
17021709
];
1703-
EventBuilder::new(Kind::ZapRequest, "", &tags)
1710+
EventBuilder::new(Kind::ZapRequest, "", tags)
17041711
.to_event(&Keys::generate())
17051712
.ok()
17061713
.map(|z| z.as_json())

mutiny-core/src/nostr/mod.rs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use lightning::{log_error, log_warn};
2323
use nostr::key::SecretKey;
2424
use nostr::nips::nip47::*;
2525
use nostr::prelude::{decrypt, encrypt};
26-
use nostr::{Event, EventBuilder, EventId, Filter, Keys, Kind, Tag};
26+
use nostr::{Event, EventBuilder, EventId, Filter, JsonUtil, Keys, Kind, Tag};
2727
use nostr_sdk::{Client, RelayPoolNotification};
2828
use std::sync::{atomic::Ordering, Arc, RwLock};
2929
use std::time::Duration;
@@ -596,9 +596,17 @@ impl<S: MutinyStorage> NostrManager<S> {
596596
)
597597
.unwrap();
598598

599-
let p_tag = Tag::PubKey(inv.pubkey, None);
600-
let e_tag = Tag::Event(inv.event_id, None, None);
601-
let response = EventBuilder::new(Kind::WalletConnectResponse, encrypted, &[p_tag, e_tag])
599+
let p_tag = Tag::PublicKey {
600+
public_key: inv.pubkey,
601+
relay_url: None,
602+
alias: None,
603+
};
604+
let e_tag = Tag::Event {
605+
event_id: inv.event_id,
606+
relay_url: None,
607+
marker: None,
608+
};
609+
let response = EventBuilder::new(Kind::WalletConnectResponse, encrypted, [p_tag, e_tag])
602610
.to_event(&nwc.server_key)
603611
.map_err(|e| MutinyError::Other(anyhow::anyhow!("Failed to create event: {e:?}")))?;
604612

@@ -725,10 +733,18 @@ impl<S: MutinyStorage> NostrManager<S> {
725733
)
726734
.unwrap();
727735

728-
let p_tag = Tag::PubKey(inv.pubkey, None);
729-
let e_tag = Tag::Event(inv.event_id, None, None);
736+
let p_tag = Tag::PublicKey {
737+
public_key: inv.pubkey,
738+
relay_url: None,
739+
alias: None,
740+
};
741+
let e_tag = Tag::Event {
742+
event_id: inv.event_id,
743+
relay_url: None,
744+
marker: None,
745+
};
730746
let response =
731-
EventBuilder::new(Kind::WalletConnectResponse, encrypted, &[p_tag, e_tag])
747+
EventBuilder::new(Kind::WalletConnectResponse, encrypted, [p_tag, e_tag])
732748
.to_event(&nwc.server_key)
733749
.map_err(|e| {
734750
MutinyError::Other(anyhow::anyhow!("Failed to create event: {e:?}"))
@@ -857,13 +873,17 @@ impl<S: MutinyStorage> NostrManager<S> {
857873
}),
858874
};
859875
let encrypted = encrypt(&nwc.secret, &nwc.public_key, req.as_json())?;
860-
let p_tag = Tag::PubKey(nwc.public_key, None);
876+
let p_tag = Tag::PublicKey {
877+
public_key: nwc.public_key,
878+
relay_url: None,
879+
alias: None,
880+
};
861881
let request_event =
862-
EventBuilder::new(Kind::WalletConnectRequest, encrypted, &[p_tag]).to_event(&secret)?;
882+
EventBuilder::new(Kind::WalletConnectRequest, encrypted, [p_tag]).to_event(&secret)?;
863883

864884
let filter = Filter::new()
865885
.kind(Kind::WalletConnectResponse)
866-
.author(nwc.public_key.to_hex())
886+
.author(nwc.public_key)
867887
.pubkey(secret.public_key())
868888
.event(request_event.id);
869889

@@ -906,9 +926,9 @@ impl<S: MutinyStorage> NostrManager<S> {
906926
select! {
907927
notification = read_fut => {
908928
match notification {
909-
Ok(RelayPoolNotification::Event(_url, event)) => {
929+
Ok(RelayPoolNotification::Event { event, .. }) => {
910930
let has_e_tag = event.tags.iter().any(|x| {
911-
if let Tag::Event(id, _, _) = x {
931+
if let Tag::Event { event_id: id, .. } = x {
912932
*id == request_event.id
913933
} else {
914934
false
@@ -935,7 +955,7 @@ impl<S: MutinyStorage> NostrManager<S> {
935955
}
936956
}
937957
},
938-
Ok(RelayPoolNotification::Message(_, _)) => {}, // ignore messages
958+
Ok(RelayPoolNotification::Message { .. }) => {}, // ignore messages
939959
Ok(RelayPoolNotification::Stop) => {}, // ignore stops
940960
Ok(RelayPoolNotification::RelayStatus { .. }) => {}, // ignore status updates
941961
Ok(RelayPoolNotification::Shutdown) =>

0 commit comments

Comments
 (0)