@@ -500,6 +514,12 @@
if (el) el.textContent = text;
}
+ function formatSats(sats) {
+ if (sats >= 1_000_000) return (sats / 1_000_000).toFixed(2).replace(/\.00$/, '') + 'M sats';
+ if (sats >= 1_000) return (sats / 1_000).toFixed(1).replace(/\.0$/, '') + 'k sats';
+ return sats.toLocaleString() + ' sats';
+ }
+
async function loadLogs() {
const logsContent = document.getElementById('logsContent');
const backendUrl = getBackendUrl();
@@ -532,6 +552,29 @@
data.channelCount = (ch.channels && ch.channels.length) || 0;
}
} catch (_) {}
+ // Balances — cards stay hidden when the endpoints are unavailable.
+ try {
+ const wRes = await fetch(backendUrl + '/proxy/lnd/v1/balance/blockchain', { credentials: 'include' });
+ if (wRes.ok) {
+ const w = await wRes.json();
+ const sats = Number(w.confirmed_balance ?? w.total_balance ?? 0);
+ if (!isNaN(sats)) {
+ setText('onchainBalance', formatSats(sats));
+ document.getElementById('onchainBalanceCard').style.display = '';
+ }
+ }
+ } catch (_) {}
+ try {
+ const cRes = await fetch(backendUrl + '/proxy/lnd/v1/balance/channels', { credentials: 'include' });
+ if (cRes.ok) {
+ const c = await cRes.json();
+ const sats = Number((c.local_balance && c.local_balance.sat) ?? c.balance ?? 0);
+ if (!isNaN(sats)) {
+ setText('channelBalance', formatSats(sats));
+ document.getElementById('channelBalanceCard').style.display = '';
+ }
+ }
+ } catch (_) {}
data.grpcReachable = data.restReachable;
applyLiveData(data);
}