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

Commit 3bc9ad9

Browse files
authored
Merge pull request #1234 from MutinyWallet/get-configured-lsp
Add function to return the current LSP
2 parents 35d4744 + 337e660 commit 3bc9ad9

5 files changed

Lines changed: 19 additions & 5 deletions

File tree

mutiny-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod labels;
2626
mod ldkstorage;
2727
pub mod lnurlauth;
2828
pub mod logging;
29-
mod lsp;
29+
pub mod lsp;
3030
mod messagehandler;
3131
mod networking;
3232
mod node;

mutiny-core/src/lsp/voltage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'de> Deserialize<'de> for VoltageConfig {
6565
}
6666

6767
#[derive(Clone)]
68-
pub(crate) struct LspClient {
68+
pub struct LspClient {
6969
pub pubkey: PublicKey,
7070
pub connection_string: String,
7171
pub url: String,

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-core/src/scorer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ fn build_preferred_hubs_set() -> HashSet<NodeId> {
277277
.collect()
278278
}
279279

280-
pub(crate) type ProbScorer = ProbabilisticScorer<Arc<NetworkGraph>, Arc<MutinyLogger>>;
280+
pub type ProbScorer = ProbabilisticScorer<Arc<NetworkGraph>, Arc<MutinyLogger>>;
281281

282-
pub(crate) struct HubPreferentialScorer {
282+
pub struct HubPreferentialScorer {
283283
inner: ProbScorer,
284284
preferred_hubs_set: HashSet<NodeId>,
285285
}

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)