diff --git a/mutiny-core/Cargo.toml b/mutiny-core/Cargo.toml index 690d3931c..75f97a3d9 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.27.0", default-features = false, features = ["nip05", "nip47", "nip57"] } -nostr-sdk = { version = "0.27.0", default-features = false, features = ["nip05", "nip47", "nip57"] } +nostr = { version = "0.27.0", default-features = false, features = ["nip04", "nip05", "nip47", "nip57"] } +nostr-sdk = { version = "0.27.0", default-features = false, features = ["nip04", "nip05", "nip47", "nip57"] } cbc = { version = "0.1", features = ["alloc"] } aes = { version = "0.8" } jwt-compact = { version = "0.8.0-beta.1", features = ["es256k"] } @@ -85,8 +85,8 @@ gloo-net = { version = "0.4.0" } instant = { version = "0.1", features = ["wasm-bindgen"] } getrandom = { version = "0.2", features = ["js"] } # add nip07 feature for wasm32 -nostr = { version = "0.27.0", default-features = false, features = ["nip05", "nip07", "nip47", "nip57"] } -nostr-sdk = { version = "0.27.0", default-features = false, features = ["nip05", "nip07", "nip47", "nip57"] } +nostr = { version = "0.27.0", default-features = false, features = ["nip04", "nip05", "nip07", "nip47", "nip57"] } +nostr-sdk = { version = "0.27.0", default-features = false, features = ["nip04", "nip05", "nip07", "nip47", "nip57"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio = { version = "1", features = ["rt"] } diff --git a/mutiny-core/src/nostr/mod.rs b/mutiny-core/src/nostr/mod.rs index bab6e01b1..02c4f62d9 100644 --- a/mutiny-core/src/nostr/mod.rs +++ b/mutiny-core/src/nostr/mod.rs @@ -1115,6 +1115,15 @@ impl NostrManager { } } + pub async fn send_dm( + &self, + pubkey: XOnlyPublicKey, + message: String, + ) -> Result { + let event_id = self.client.send_direct_msg(pubkey, message, None).await?; + Ok(event_id) + } + /// Derives the client and server keys for Nostr Wallet Connect given a profile index /// The left key is the client key and the right key is the server key pub(crate) fn derive_nwc_keys( diff --git a/mutiny-wasm/Cargo.toml b/mutiny-wasm/Cargo.toml index 99c1b6040..3129cc47d 100644 --- a/mutiny-wasm/Cargo.toml +++ b/mutiny-wasm/Cargo.toml @@ -30,7 +30,7 @@ lightning-invoice = { version = "0.26.0" } thiserror = "1.0" instant = { version = "0.1", features = ["wasm-bindgen"] } lnurl-rs = { version = "0.3.1", default-features = false } -nostr = { version = "0.27.0", default-features = false, features = ["nip05", "nip07", "nip47", "nip57"] } +nostr = { version = "0.27.0", default-features = false, features = ["nip04", "nip05", "nip07", "nip47", "nip57"] } wasm-logger = "0.2.0" log = "0.4.17" rexie = "0.5.0" diff --git a/mutiny-wasm/src/lib.rs b/mutiny-wasm/src/lib.rs index 65b70d949..466d84f14 100644 --- a/mutiny-wasm/src/lib.rs +++ b/mutiny-wasm/src/lib.rs @@ -1626,6 +1626,13 @@ impl MutinyWallet { Ok(JsValue::from_serde(&dms)?) } + /// Sends a DM to the given npub + pub async fn send_dm(&self, npub: String, message: String) -> Result { + let npub = parse_npub(&npub)?; + let event_id = self.inner.nostr.send_dm(npub, message).await?; + Ok(event_id.to_hex()) + } + /// Resets the scorer and network graph. This can be useful if you get stuck in a bad state. #[wasm_bindgen] pub async fn reset_router(&self) -> Result<(), MutinyJsError> {