Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.
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
2 changes: 1 addition & 1 deletion mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod labels;
mod ldkstorage;
pub mod lnurlauth;
pub mod logging;
mod lsp;
pub mod lsp;
mod messagehandler;
mod networking;
mod node;
Expand Down
2 changes: 1 addition & 1 deletion mutiny-core/src/lsp/voltage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'de> Deserialize<'de> for VoltageConfig {
}

#[derive(Clone)]
pub(crate) struct LspClient {
pub struct LspClient {
pub pubkey: PublicKey,
pub connection_string: String,
pub url: String,
Expand Down
5 changes: 5 additions & 0 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,11 @@ impl<S: MutinyStorage> NodeManager<S> {
Ok(peers)
}

pub async fn get_configured_lsp(&self) -> Result<Option<LspConfig>, 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.
///
Expand Down
4 changes: 2 additions & 2 deletions mutiny-core/src/scorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ fn build_preferred_hubs_set() -> HashSet<NodeId> {
.collect()
}

pub(crate) type ProbScorer = ProbabilisticScorer<Arc<NetworkGraph>, Arc<MutinyLogger>>;
pub type ProbScorer = ProbabilisticScorer<Arc<NetworkGraph>, Arc<MutinyLogger>>;

pub(crate) struct HubPreferentialScorer {
pub struct HubPreferentialScorer {
inner: ProbScorer,
preferred_hubs_set: HashSet<NodeId>,
}
Expand Down
11 changes: 10 additions & 1 deletion mutiny-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -763,6 +763,15 @@ impl MutinyWallet {
Ok(())
}

/// Returns the current LSP config
pub async fn get_configured_lsp(&self) -> Result<JsValue, MutinyJsError> {
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(
Expand Down