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

Commit 7390372

Browse files
Merge pull request #905 from MutinyWallet/nostr-26
Update rust-nostr to v0.26
2 parents f17881b + 131bab4 commit 7390372

9 files changed

Lines changed: 310 additions & 151 deletions

File tree

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: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use crate::{
6666
use crate::{nodemanager::NodeManager, nostr::ProfileType};
6767
use crate::{nostr::NostrManager, utils::sleep};
6868
use ::nostr::key::XOnlyPublicKey;
69-
use ::nostr::{Event, Kind, Metadata};
69+
use ::nostr::{Event, JsonUtil, Kind, Metadata};
7070
use bdk_chain::ConfirmationTime;
7171
use bip39::Mnemonic;
7272
use bitcoin::util::bip32::ExtendedPrivKey;
@@ -473,19 +473,12 @@ impl<S: MutinyStorage> MutinyWallet<S> {
473473
log_warn!(logger, "Failed to clear expired NWC invoices: {e}");
474474
}
475475

476-
// clear successful single-use profiles
477-
478476
let client = Client::new(&nostr.primary_key);
479477

480-
#[cfg(target_arch = "wasm32")]
481-
let add_relay_res = client.add_relays(nostr.get_relays()).await;
482-
483-
#[cfg(not(target_arch = "wasm32"))]
484-
let add_relay_res = client
485-
.add_relays(nostr.get_relays().into_iter().map(|s| (s, None)).collect())
486-
.await;
487-
488-
add_relay_res.expect("Failed to add relays");
478+
client
479+
.add_relays(nostr.get_relays())
480+
.await
481+
.expect("Failed to add relays");
489482
client.connect().await;
490483

491484
let mut last_filters = nostr.get_nwc_filters();
@@ -513,7 +506,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
513506
select! {
514507
notification = read_fut => {
515508
match notification {
516-
Ok(RelayPoolNotification::Event(_url, event)) => {
509+
Ok(RelayPoolNotification::Event { event, .. }) => {
517510
if event.kind == Kind::WalletConnectRequest && event.verify().is_ok() {
518511
match nostr.handle_nwc_request(event, &self_clone).await {
519512
Ok(Some(event)) => {
@@ -528,7 +521,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
528521
}
529522
}
530523
},
531-
Ok(RelayPoolNotification::Message(_, _)) => {}, // ignore messages
524+
Ok(RelayPoolNotification::Message { .. }) => {}, // ignore messages
532525
Ok(RelayPoolNotification::Shutdown) => break, // if we disconnect, we restart to reconnect
533526
Ok(RelayPoolNotification::Stop) => {}, // Currently unused
534527
Ok(RelayPoolNotification::RelayStatus { .. }) => {}, // Currently unused

mutiny-core/src/nodemanager.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use lightning_transaction_sync::EsploraSyncClient;
4949
use lnurl::lnurl::LnUrl;
5050
use lnurl::{AsyncClient as LnUrlClient, LnUrlResponse, Response};
5151
use nostr::key::XOnlyPublicKey;
52-
use nostr::{EventBuilder, Keys, Kind, Tag, TagKind};
52+
use nostr::{EventBuilder, JsonUtil, Keys, Kind, Tag, TagKind};
5353
use payjoin::{PjUri, PjUriExt};
5454
use reqwest::Client;
5555
use serde::{Deserialize, Serialize};
@@ -1617,13 +1617,20 @@ impl<S: MutinyStorage> NodeManager<S> {
16171617
let zap_request = match zap_npub {
16181618
Some(zap_npub) => {
16191619
let tags = vec![
1620-
Tag::PubKey(zap_npub, None),
1621-
Tag::Amount(msats),
1620+
Tag::PublicKey {
1621+
public_key: zap_npub,
1622+
relay_url: None,
1623+
alias: None,
1624+
},
1625+
Tag::Amount {
1626+
millisats: msats,
1627+
bolt11: None,
1628+
},
16221629
Tag::Lnurl(lnurl.to_string()),
16231630
Tag::Relays(vec!["wss://nostr.mutinywallet.com".into()]),
16241631
Tag::Generic(TagKind::Custom("anon".to_string()), vec![]),
16251632
];
1626-
EventBuilder::new(Kind::ZapRequest, "", &tags)
1633+
EventBuilder::new(Kind::ZapRequest, "", tags)
16271634
.to_event(&Keys::generate())
16281635
.ok()
16291636
.map(|z| z.as_json())

0 commit comments

Comments
 (0)