From 28475c0da5e1975d83a7ec3b71f4efa6a50ea6d4 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 3 Jul 2024 11:48:35 -0500 Subject: [PATCH] Correctly display the currently in use LSP --- src/routes/settings/Servers.tsx | 33 ++++++++++++++++++++++++--------- src/workers/walletWorker.ts | 16 ++++++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/routes/settings/Servers.tsx b/src/routes/settings/Servers.tsx index 9600d9ff..75b3d4d9 100644 --- a/src/routes/settings/Servers.tsx +++ b/src/routes/settings/Servers.tsx @@ -9,6 +9,7 @@ import { ExternalLink, LargeHeader, LoadingShimmer, + MutinyWalletGuard, NavBar, NiceP, showToast, @@ -255,7 +256,19 @@ function SettingsStringsEditor(props: { } function AsyncSettingsEditor() { - const [settings] = createResource(getSettings); + const [_state, _actions, sw] = useMegaStore(); + + const [settings] = createResource(async () => { + const settings = await getSettings(); + + // set the lsp to what the node manager is using + const lsp = await sw.get_configured_lsp(); + settings.lsp = lsp.url; + settings.lsps_connection_string = lsp.connection_string; + settings.lsps_token = lsp.token; + + return settings; + }); return ( @@ -272,13 +285,15 @@ function AsyncSettingsEditor() { export function Servers() { const i18n = useI18n(); return ( - - - {i18n.t("settings.servers.title")} - }> - - - - + + + + {i18n.t("settings.servers.title")} + }> + + + + + ); } diff --git a/src/workers/walletWorker.ts b/src/workers/walletWorker.ts index 6ee55ee1..338b5102 100644 --- a/src/workers/walletWorker.ts +++ b/src/workers/walletWorker.ts @@ -612,6 +612,7 @@ export async function estimate_tx_fee( const fee = await wallet!.estimate_tx_fee(address, amount, feeRate); return fee; } + /** * Calls upon a LNURL to get the parameters for it. * This contains what kind of LNURL it is (pay, withdrawal, auth, etc). @@ -1245,6 +1246,21 @@ export async function change_lsp( await wallet!.change_lsp(lsp_url, lsp_connection_string, lsps_token); } +type LspConfig = { + url?: string; + connection_string?: string; + token?: string; +}; + +/** + * Returns the configured LSP for the node manager. + * + * @returns {Promise} + */ +export async function get_configured_lsp(): Promise { + return await wallet!.get_configured_lsp(); +} + /** * Resets BDK's keychain tracker. This will require a re-sync of the blockchain. *