Show NWC manager in Wallet Connections modal

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
This commit is contained in:
naturallaw777
2026-07-28 20:44:44 +00:00
co-authored by arena-agent
parent 1a6e456d06
commit a4f848fc6d
2 changed files with 24 additions and 7 deletions
@@ -63,6 +63,10 @@ async function apiFetch(path, options) {
} else if (body.detail && typeof body.detail.message === "string") { } else if (body.detail && typeof body.detail.message === "string") {
detail = body.detail.message; detail = body.detail.message;
} }
} else if (body && typeof body.message === "string") {
detail = body.message;
} else if (body && typeof body.error === "string") {
detail = body.error;
} }
} catch (e) {} } catch (e) {}
throw new Error(detail); throw new Error(detail);
@@ -60,6 +60,13 @@ function _attachCopyHandlers(container) {
var _nwcModalState = null; var _nwcModalState = null;
function _isNwcServiceUnit(unit) {
// The dashboard tile is backed by Alby Hub, while older drafts referred to
// the logical feature as nwc-wallets.service. Support both so the Wallet
// Connections manager appears from the actual tile and any legacy configs.
return unit === "albyhub.service" || unit === "nwc-wallets.service";
}
function _nwcStateMessageHtml() { function _nwcStateMessageHtml() {
if (!_nwcModalState || !_nwcModalState.message) return ""; if (!_nwcModalState || !_nwcModalState.message) return "";
var msgClass = _nwcModalState.messageKind === "success" ? "success" : "error"; var msgClass = _nwcModalState.messageKind === "success" ? "success" : "error";
@@ -171,14 +178,15 @@ function _nwcRenderWalletState() {
return; return;
} }
var canCreate = !!state.domain && !state.busy;
html += '<div class="matrix-actions-row">' + html += '<div class="matrix-actions-row">' +
'<button class="matrix-action-btn" id="nwc-open-create-btn"' + (state.busy ? " disabled" : "") + '> Create Wallet Connection</button>' + '<button class="matrix-action-btn" id="nwc-open-create-btn"' + (canCreate ? "" : " disabled") + '>' + (state.domain ? ' Create Wallet Connection' : 'Configure Domain First') + '</button>' +
'<button class="matrix-form-back" id="nwc-refresh-btn"' + (state.busy ? " disabled" : "") + '>Refresh</button>' + '<button class="matrix-form-back" id="nwc-refresh-btn"' + (state.busy ? " disabled" : "") + '>Refresh</button>' +
'</div>'; '</div>';
if (state.domain) { if (state.domain) {
html += '<p class="svc-detail-desc">Lightning Address domain: <strong>' + escHtml(state.domain) + '</strong></p>'; html += '<p class="svc-detail-desc">Lightning Address domain: <strong>' + escHtml(state.domain) + '</strong></p>';
} else { } else {
html += '<p class="svc-detail-desc">Lightning Address domain is not configured yet. Configure your domain first, then create wallet connections.</p>'; html += '<div class="svc-detail-troubleshoot" style="margin-bottom:10px"><strong>Domain required</strong><div style="margin-top:6px">Configure the Lightning Address domain in the Domain Diagnostic Checklist above before creating Wallet Connections. Use a unique hostname such as <strong>lightning.yourdomain.com</strong>.</div></div>';
} }
if (!state.wallets || state.wallets.length === 0) { if (!state.wallets || state.wallets.length === 0) {
@@ -595,11 +603,16 @@ async function openServiceDetailModal(unit, name, icon) {
} }
// Section E: Credentials & Links // Section E: Credentials & Links
if (unit === "nwc-wallets.service") { if (_isNwcServiceUnit(unit)) {
html += '<div class="svc-detail-section">' + html += '<div class="svc-detail-section">' +
'<div class="svc-detail-section-title">Wallet Connections</div>' + '<div class="svc-detail-section-title">Wallet Connections</div>';
'<div id="nwc-wallets-body"><p class="creds-loading">Loading wallet connections…</p></div>' + if (effectiveEnabled || data.enabled) {
'</div>'; html += '<p class="svc-detail-desc">Create, verify, drain, and delete isolated NWC wallet connections without leaving the Hub.</p>' +
'<div id="nwc-wallets-body"><p class="creds-loading">Loading wallet connections…</p></div>';
} else {
html += '<p class="creds-empty">Wallet Connections is disabled. Enable this feature below, rebuild, then return here to create and manage NWC wallet connections.</p>';
}
html += '</div>';
} else if (data.has_credentials && data.credentials && data.credentials.length > 0) { } else if (data.has_credentials && data.credentials && data.credentials.length > 0) {
html += '<div class="svc-detail-section">' + html += '<div class="svc-detail-section">' +
'<div class="svc-detail-section-title">Credentials &amp; Access</div>' + '<div class="svc-detail-section-title">Credentials &amp; Access</div>' +
@@ -681,7 +694,7 @@ async function openServiceDetailModal(unit, name, icon) {
$credsBody.innerHTML = html; $credsBody.innerHTML = html;
_attachCopyHandlers($credsBody); _attachCopyHandlers($credsBody);
if (unit === "nwc-wallets.service") { if (_isNwcServiceUnit(unit) && (effectiveEnabled || data.enabled)) {
await _nwcInitWalletFlow(unit, name, icon); await _nwcInitWalletFlow(unit, name, icon);
} }