diff --git a/Cargo.lock b/Cargo.lock index 90241f937..d4645e0af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -207,6 +207,24 @@ dependencies = [ "wasm-bindgen-futures", ] +[[package]] +name = "async-wsocket" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d55992e9155e571208dc012c2a5c056572d1ab167bc299a63810ebf910226c" +dependencies = [ + "async-utility", + "futures-util", + "thiserror", + "tokio", + "tokio-rustls 0.24.1", + "tokio-socks", + "tokio-tungstenite 0.20.1", + "url-fork", + "wasm-ws", + "webpki-roots", +] + [[package]] name = "async_io_stream" version = "0.3.3" @@ -763,29 +781,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crossbeam-deque" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", -] - [[package]] name = "crossbeam-utils" version = "0.8.17" @@ -2454,15 +2449,6 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mime" version = "0.3.17" @@ -2668,8 +2654,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nostr" -version = "0.26.0" -source = "git+https://github.com/benthecarman/nostr.git?rev=7195b8d537db5fe0612b3d94794893bc0021aa11#7195b8d537db5fe0612b3d94794893bc0021aa11" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e47228d958fd65ef3e04650a3b1dd80f16f10f0243c80ed969556dead0f48c8" dependencies = [ "aes", "base64 0.21.5", @@ -2686,16 +2673,17 @@ dependencies = [ "serde_json", "tracing", "url-fork", + "wasm-bindgen", ] [[package]] name = "nostr-database" -version = "0.26.0" -source = "git+https://github.com/benthecarman/nostr.git?rev=7195b8d537db5fe0612b3d94794893bc0021aa11#7195b8d537db5fe0612b3d94794893bc0021aa11" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa0550256c8d4f0aaf74891ac986bd5ba46b2957c2c7e20f51838fa5819285f8" dependencies = [ "async-trait", "nostr", - "rayon", "thiserror", "tokio", "tracing", @@ -2703,35 +2691,20 @@ dependencies = [ [[package]] name = "nostr-sdk" -version = "0.26.0" -source = "git+https://github.com/benthecarman/nostr.git?rev=7195b8d537db5fe0612b3d94794893bc0021aa11#7195b8d537db5fe0612b3d94794893bc0021aa11" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cf190e41230721f0ce64f5ea72ed36cbc431d3b305eb166e24a94f5d7e4a425" dependencies = [ "async-utility", + "async-wsocket", "nostr", "nostr-database", - "nostr-sdk-net", "once_cell", "thiserror", "tokio", "tracing", ] -[[package]] -name = "nostr-sdk-net" -version = "0.26.0" -source = "git+https://github.com/benthecarman/nostr.git?rev=7195b8d537db5fe0612b3d94794893bc0021aa11#7195b8d537db5fe0612b3d94794893bc0021aa11" -dependencies = [ - "futures-util", - "thiserror", - "tokio", - "tokio-rustls 0.24.1", - "tokio-socks", - "tokio-tungstenite 0.20.1", - "url-fork", - "wasm-ws", - "webpki-roots", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2793,9 +2766,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -3217,26 +3190,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "rayon" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -3726,6 +3679,7 @@ version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ + "indexmap 2.1.0", "itoa", "ryu", "serde", diff --git a/Cargo.toml b/Cargo.toml index ec9cfd94a..c459bd9bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,5 +20,3 @@ lightning-invoice = { git = 'https://github.com/MutinyWallet/rust-lightning.git' lightning-rapid-gossip-sync = { git = 'https://github.com/MutinyWallet/rust-lightning.git', rev = "686a84236f54bf8d7270a5fbec07801e5281691f" } lightning-background-processor = { git = 'https://github.com/MutinyWallet/rust-lightning.git', rev = "686a84236f54bf8d7270a5fbec07801e5281691f" } lightning-transaction-sync = { git = 'https://github.com/MutinyWallet/rust-lightning.git', rev = "686a84236f54bf8d7270a5fbec07801e5281691f" } -nostr = { git = 'https://github.com/benthecarman/nostr.git', rev = "7195b8d537db5fe0612b3d94794893bc0021aa11" } -nostr-sdk = { git = 'https://github.com/benthecarman/nostr.git', rev = "7195b8d537db5fe0612b3d94794893bc0021aa11" } diff --git a/mutiny-core/Cargo.toml b/mutiny-core/Cargo.toml index ab273e7c7..507beabfc 100644 --- a/mutiny-core/Cargo.toml +++ b/mutiny-core/Cargo.toml @@ -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.26.0", default-features = false, features = ["nip05", "nip47"] } -nostr-sdk = { version = "0.26.0", default-features = false } +nostr = { version = "0.27.0", default-features = false, features = ["nip05", "nip47", "nip57"] } +nostr-sdk = { version = "0.27.0", default-features = false } cbc = { version = "0.1", features = ["alloc"] } aes = { version = "0.8" } jwt-compact = { version = "0.8.0-beta.1", features = ["es256k"] } diff --git a/mutiny-core/src/error.rs b/mutiny-core/src/error.rs index d19de1e35..6a545a88e 100644 --- a/mutiny-core/src/error.rs +++ b/mutiny-core/src/error.rs @@ -463,6 +463,12 @@ impl From for MutinyError { } } +impl From for MutinyError { + fn from(_e: nostr::nips::nip57::Error) -> Self { + Self::NostrError + } +} + impl From for MutinyError { fn from(e: nip05::Error) -> Self { match e { diff --git a/mutiny-core/src/lib.rs b/mutiny-core/src/lib.rs index 7fab3a775..739dc1891 100644 --- a/mutiny-core/src/lib.rs +++ b/mutiny-core/src/lib.rs @@ -68,7 +68,9 @@ use crate::{ }; use crate::{nostr::NostrManager, utils::sleep}; use ::nostr::key::XOnlyPublicKey; -use ::nostr::{EventBuilder, JsonUtil, Keys, Kind, Tag}; +use ::nostr::nips::nip57; +use ::nostr::prelude::ZapRequestData; +use ::nostr::{JsonUtil, Kind}; use async_lock::RwLock; use bdk_chain::ConfirmationTime; use bip39::Mnemonic; @@ -1511,25 +1513,21 @@ impl MutinyWallet { // if user's npub is given, do an anon zap let (zap_request, comment) = match zap_npub { Some(zap_npub) => { - let tags = vec![ - 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::Anon { msg: comment }, - ]; - let event = EventBuilder::new(Kind::ZapRequest, "", tags) - .to_event(&Keys::generate())? - .as_json(); - - (Some(event), None) + let data = ZapRequestData { + public_key: zap_npub, + relays: vec![ + "wss://nostr.mutinywallet.com".into(), + "wss://relay.primal.net".into(), + ], + message: comment.unwrap_or_default(), + amount: Some(msats), + lnurl: Some(lnurl.encode()), + event_id: None, + event_coordinate: None, + }; + let event = nip57::anonymous_zap_request(data)?; + + (Some(event.as_json()), None) } None => (None, comment.filter(|c| !c.is_empty())), }; diff --git a/mutiny-core/src/nostr/mod.rs b/mutiny-core/src/nostr/mod.rs index 5fe87bed8..30237685b 100644 --- a/mutiny-core/src/nostr/mod.rs +++ b/mutiny-core/src/nostr/mod.rs @@ -587,6 +587,7 @@ impl NostrManager { public_key: inv.pubkey, relay_url: None, alias: None, + uppercase: false, }; let e_tag = Tag::Event { event_id: inv.event_id, @@ -718,6 +719,7 @@ impl NostrManager { public_key: inv.pubkey, relay_url: None, alias: None, + uppercase: false, }; let e_tag = Tag::Event { event_id: inv.event_id, @@ -855,6 +857,7 @@ impl NostrManager { public_key: nwc.public_key, relay_url: None, alias: None, + uppercase: false, }; let request_event = EventBuilder::new(Kind::WalletConnectRequest, encrypted, [p_tag]).to_event(&secret)?; diff --git a/mutiny-core/src/nostr/nwc.rs b/mutiny-core/src/nostr/nwc.rs index 8ef5ec77a..5dac64a6c 100644 --- a/mutiny-core/src/nostr/nwc.rs +++ b/mutiny-core/src/nostr/nwc.rs @@ -390,6 +390,7 @@ impl NostrWalletConnect { public_key: event.pubkey, relay_url: None, alias: None, + uppercase: false, }; let e_tag = Tag::Event { event_id: event.id, @@ -625,6 +626,7 @@ impl NostrWalletConnect { public_key: event.pubkey, relay_url: None, alias: None, + uppercase: false, }; let e_tag = Tag::Event { event_id: event.id, @@ -794,6 +796,7 @@ impl NostrWalletConnect { public_key: event.pubkey, relay_url: None, alias: None, + uppercase: false, }; let e_tag = Tag::Event { event_id: event.id, @@ -1318,6 +1321,7 @@ mod wasm_test { public_key: uri.public_key, relay_url: None, alias: None, + uppercase: false, }; EventBuilder::new(Kind::WalletConnectRequest, encrypted, [p_tag]) .to_event(&Keys::new(uri.secret)) @@ -1346,6 +1350,7 @@ mod wasm_test { public_key: uri.public_key, relay_url: None, alias: None, + uppercase: false, }; EventBuilder::new(Kind::WalletConnectRequest, encrypted, [p_tag]) .to_event(&Keys::new(uri.secret)) diff --git a/mutiny-core/src/test_utils.rs b/mutiny-core/src/test_utils.rs index 2d2b024d7..e49ac7c7d 100644 --- a/mutiny-core/src/test_utils.rs +++ b/mutiny-core/src/test_utils.rs @@ -48,6 +48,7 @@ pub fn create_nwc_request(nwc: &NostrWalletConnectURI, invoice: String) -> Event public_key: nwc.public_key, relay_url: None, alias: None, + uppercase: false, }; EventBuilder::new(Kind::WalletConnectRequest, encrypted, [p_tag]) diff --git a/mutiny-core/src/utils.rs b/mutiny-core/src/utils.rs index e164f904c..2abc5592f 100644 --- a/mutiny-core/src/utils.rs +++ b/mutiny-core/src/utils.rs @@ -188,7 +188,7 @@ pub(crate) fn parse_profile_metadata(data: Vec) -> HashMap