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

Commit 337e660

Browse files
committed
Add function to return the current LSP
1 parent 960a4e8 commit 337e660

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

mutiny-core/src/nodemanager.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,11 @@ impl<S: MutinyStorage> NodeManager<S> {
13441344
Ok(peers)
13451345
}
13461346

1347+
pub async fn get_configured_lsp(&self) -> Result<Option<LspConfig>, MutinyError> {
1348+
let node = self.get_node_by_key_or_first(None).await?;
1349+
Ok(node.node_index().await.lsp)
1350+
}
1351+
13471352
/// Changes all the node's LSPs to the given config. If any of the nodes have an active channel with the
13481353
/// current LSP, it will fail to change the LSP.
13491354
///

mutiny-wasm/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use mutiny_core::{
4747
labels::LabelStorage,
4848
nodemanager::{create_lsp_config, NodeManager},
4949
};
50-
use mutiny_core::{logging::MutinyLogger, nostr::ProfileType};
50+
use mutiny_core::{logging::MutinyLogger, lsp::LspConfig, nostr::ProfileType};
5151
use nostr::prelude::Method;
5252
use nostr::{Keys, ToBech32};
5353
use std::collections::HashMap;
@@ -763,6 +763,15 @@ impl MutinyWallet {
763763
Ok(())
764764
}
765765

766+
/// Returns the current LSP config
767+
pub async fn get_configured_lsp(&self) -> Result<JsValue, MutinyJsError> {
768+
match self.inner.node_manager.get_configured_lsp().await? {
769+
Some(LspConfig::VoltageFlow(config)) => Ok(JsValue::from_serde(&config)?),
770+
Some(LspConfig::Lsps(config)) => Ok(JsValue::from_serde(&config)?),
771+
None => Ok(JsValue::NULL),
772+
}
773+
}
774+
766775
/// Attempts to connect to a peer from the selected node.
767776
#[wasm_bindgen]
768777
pub async fn connect_to_peer(

0 commit comments

Comments
 (0)