diff --git a/mutiny-core/src/nodemanager.rs b/mutiny-core/src/nodemanager.rs index 43b0e2699..e7039c10d 100644 --- a/mutiny-core/src/nodemanager.rs +++ b/mutiny-core/src/nodemanager.rs @@ -1344,6 +1344,11 @@ impl NodeManager { Ok(peers) } + pub async fn get_configured_lsp(&self) -> Result, MutinyError> { + let node = self.get_node_by_key_or_first(None).await?; + Ok(node.node_index().await.lsp) + } + /// Changes all the node's LSPs to the given config. If any of the nodes have an active channel with the /// current LSP, it will fail to change the LSP. /// diff --git a/mutiny-wasm/src/lib.rs b/mutiny-wasm/src/lib.rs index 47197caef..8d22c263a 100644 --- a/mutiny-wasm/src/lib.rs +++ b/mutiny-wasm/src/lib.rs @@ -47,7 +47,7 @@ use mutiny_core::{ labels::LabelStorage, nodemanager::{create_lsp_config, NodeManager}, }; -use mutiny_core::{logging::MutinyLogger, nostr::ProfileType}; +use mutiny_core::{logging::MutinyLogger, lsp::LspConfig, nostr::ProfileType}; use nostr::prelude::Method; use nostr::{Keys, ToBech32}; use std::collections::HashMap; @@ -763,6 +763,15 @@ impl MutinyWallet { Ok(()) } + /// Returns the current LSP config + pub async fn get_configured_lsp(&self) -> Result { + match self.inner.node_manager.get_configured_lsp().await? { + Some(LspConfig::VoltageFlow(config)) => Ok(JsValue::from_serde(&config)?), + Some(LspConfig::Lsps(config)) => Ok(JsValue::from_serde(&config)?), + None => Ok(JsValue::NULL), + } + } + /// Attempts to connect to a peer from the selected node. #[wasm_bindgen] pub async fn connect_to_peer(