Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rust-nostr to v0.26 #905

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 107 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions mutiny-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ futures-util = { version = "0.3", default-features = false }
reqwest = { version = "0.11", default-features = false, features = ["json"] }
async-trait = "0.1.68"
url = { version = "2.3.1", features = ["serde"] }
nostr = { version = "0.24.0", default-features = false, features = ["nip47"] }
nostr-sdk = { version = "0.24.0", default-features = false }
nostr = { version = "0.26.0", default-features = false, features = ["nip47"] }
nostr-sdk = { version = "0.26.0", default-features = false }
cbc = { version = "0.1", features = ["alloc"] }
aes = { version = "0.8" }
jwt-compact = { version = "0.8.0-beta.1", features = ["es256k"] }
Expand Down
21 changes: 7 additions & 14 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use crate::{
use crate::{nodemanager::NodeManager, nostr::ProfileType};
use crate::{nostr::NostrManager, utils::sleep};
use ::nostr::key::XOnlyPublicKey;
use ::nostr::{Event, Kind, Metadata};
use ::nostr::{Event, JsonUtil, Kind, Metadata};
use bdk_chain::ConfirmationTime;
use bip39::Mnemonic;
use bitcoin::util::bip32::ExtendedPrivKey;
Expand Down Expand Up @@ -479,19 +479,12 @@ impl<S: MutinyStorage> MutinyWallet<S> {
log_warn!(logger, "Failed to clear expired NWC invoices: {e}");
}

// clear successful single-use profiles

let client = Client::new(&nostr.primary_key);

#[cfg(target_arch = "wasm32")]
let add_relay_res = client.add_relays(nostr.get_relays()).await;

#[cfg(not(target_arch = "wasm32"))]
let add_relay_res = client
.add_relays(nostr.get_relays().into_iter().map(|s| (s, None)).collect())
.await;

add_relay_res.expect("Failed to add relays");
client
.add_relays(nostr.get_relays())
.await
.expect("Failed to add relays");
client.connect().await;

let mut last_filters = nostr.get_nwc_filters();
Expand Down Expand Up @@ -519,7 +512,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
select! {
notification = read_fut => {
match notification {
Ok(RelayPoolNotification::Event(_url, event)) => {
Ok(RelayPoolNotification::Event { event, .. }) => {
if event.kind == Kind::WalletConnectRequest && event.verify().is_ok() {
match nostr.handle_nwc_request(event, &self_clone).await {
Ok(Some(event)) => {
Expand All @@ -534,7 +527,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
}
}
},
Ok(RelayPoolNotification::Message(_, _)) => {}, // ignore messages
Ok(RelayPoolNotification::Message { .. }) => {}, // ignore messages
Ok(RelayPoolNotification::Shutdown) => break, // if we disconnect, we restart to reconnect
Ok(RelayPoolNotification::Stop) => {}, // Currently unused
Ok(RelayPoolNotification::RelayStatus { .. }) => {}, // Currently unused
Expand Down
15 changes: 11 additions & 4 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use lightning_transaction_sync::EsploraSyncClient;
use lnurl::lnurl::LnUrl;
use lnurl::{AsyncClient as LnUrlClient, LnUrlResponse, Response};
use nostr::key::XOnlyPublicKey;
use nostr::{EventBuilder, Keys, Kind, Tag, TagKind};
use nostr::{EventBuilder, JsonUtil, Keys, Kind, Tag, TagKind};
use payjoin::{PjUri, PjUriExt};
use reqwest::Client;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -1694,13 +1694,20 @@ impl<S: MutinyStorage> NodeManager<S> {
let zap_request = match zap_npub {
Some(zap_npub) => {
let tags = vec![
Tag::PubKey(zap_npub, None),
Tag::Amount(msats),
Tag::PublicKey {
public_key: zap_npub,
relay_url: None,
alias: None,
},
Tag::Amount {
millisats: msats,
bolt11: None,
},
Tag::Lnurl(lnurl.to_string()),
Tag::Relays(vec!["wss://nostr.mutinywallet.com".into()]),
Tag::Generic(TagKind::Custom("anon".to_string()), vec![]),
];
EventBuilder::new(Kind::ZapRequest, "", &tags)
EventBuilder::new(Kind::ZapRequest, "", tags)
.to_event(&Keys::generate())
.ok()
.map(|z| z.as_json())
Expand Down
Loading
Loading