Skip to content

Commit

Permalink
Correctly display the currently in use LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jul 3, 2024
1 parent 5bcfb55 commit 28475c0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/routes/settings/Servers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ExternalLink,
LargeHeader,
LoadingShimmer,
MutinyWalletGuard,
NavBar,
NiceP,
showToast,
Expand Down Expand Up @@ -255,7 +256,19 @@ function SettingsStringsEditor(props: {
}

function AsyncSettingsEditor() {
const [settings] = createResource<MutinyWalletSettingStrings>(getSettings);
const [_state, _actions, sw] = useMegaStore();

const [settings] = createResource<MutinyWalletSettingStrings>(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 (
<Switch>
Expand All @@ -272,13 +285,15 @@ function AsyncSettingsEditor() {
export function Servers() {
const i18n = useI18n();
return (
<DefaultMain>
<BackLink href="/settings" title={i18n.t("settings.header")} />
<LargeHeader>{i18n.t("settings.servers.title")}</LargeHeader>
<Suspense fallback={<LoadingShimmer />}>
<AsyncSettingsEditor />
</Suspense>
<NavBar activeTab="settings" />
</DefaultMain>
<MutinyWalletGuard>
<DefaultMain>
<BackLink href="/settings" title={i18n.t("settings.header")} />
<LargeHeader>{i18n.t("settings.servers.title")}</LargeHeader>
<Suspense fallback={<LoadingShimmer />}>
<AsyncSettingsEditor />
</Suspense>
<NavBar activeTab="settings" />
</DefaultMain>
</MutinyWalletGuard>
);
}
16 changes: 16 additions & 0 deletions src/workers/walletWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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<LspConfig>}
*/
export async function get_configured_lsp(): Promise<LspConfig> {
return await wallet!.get_configured_lsp();
}

/**
* Resets BDK's keychain tracker. This will require a re-sync of the blockchain.
*
Expand Down

0 comments on commit 28475c0

Please sign in to comment.