Introducing a new way to review your PRs.

Read the announcement

jamaljsr / polar

One-click Bitcoin Lightning networks for local app development & testing

View on GitHub

19 documents · Updated Oct 19, 2026

docs / backend-proxy-services

Backend proxy services

Backend proxy services connect the application to local LND, Litd, and Tapd nodes through the Electron main process. They keep node API access and credential use at the desktop boundary while giving renderer-side services one request path for node actions and events. See Electron desktop runtime for the parent runtime view and Desktop MCP integration for the related desktop tool path.

Proxy boundary

The proxy boundary separates application features from local node connections. A renderer-side proxy client sends a typed request over Electron IPC, and the matching main-process proxy selects the target node and calls its local API.

The request carries a node description rather than a public network address. The main process uses that description to reach the node on loopback and to load the certificate and macaroon needed for an authenticated connection. The proxy returns the service result or an error response to the waiting renderer request.

The main process starts all three service proxies when the application is ready. It also clears their cached connections when the main window reloads or when the application receives its general cache-clear request.

The request path has these stages:

  1. A feature service calls the service-specific renderer client.
  2. The client sends a request with a node and, when needed, request data.
  3. The Electron main process routes the IPC channel to the matching proxy action.
  4. The proxy uses the node's local endpoint and credentials to call the backend.
  5. The result crosses IPC after response shaping and binary-value conversion where the service needs it.

The following diagram shows the shared request boundary and the three service-specific paths.

flowchart LR
    Feature[Application feature] --> Client[Renderer proxy client]
    Client --> IPC[Electron IPC]
    IPC --> Router[Main-process proxy listener]
    Router --> LND[LND proxy]
    Router --> Litd[Litd proxy]
    Router --> Tapd[Tapd proxy]
    LND --> LNDNode[Local LND node]
    Litd --> LitdNode[Local Litd node]
    Tapd --> TapdNode[Local Tapd node]
    LND --> IPC
    Litd --> IPC
    Tapd --> IPC
    IPC --> Client

References: electron/windowManager.ts• L22-32 electron/windowManager.ts• L84-85 electron/appIpcListener.ts• L50-70 src/…/ipcService.ts• L30-59 src/…/types.ts• L9-21

Request and response channels

Each service uses a request channel and a response channel with a service prefix. The renderer adds a unique reply channel to each request, so concurrent calls do not share a response listener. Stream subscriptions use a related stream channel and remain active until the client removes the listener.

Proxy failures cross the same boundary as data. The main process sends an error field, and the renderer IPC sender turns that field into a rejected promise for the calling service.

References: src/…/ipcService.ts• L5-13 src/…/ipcService.ts• L36-59 src/…/ipcService.ts• L65-90 electron/…/lndProxyServer.ts• L223-251

Connection cache

The service proxies keep one backend client per network and node name. This avoids rebuilding a client and rereading credentials for each call. The application clears these caches when the window reloads and through the app-level cache command so later requests rebuild connections from current node data.

The LND proxy uses separate TLS-only clients for wallet state and wallet setup. After wallet initialization or unlock, it clears all LND client caches because those actions restart the LND RPC server.

References: electron/…/lndProxyServer.ts• L28-51 electron/…/lndProxyServer.ts• L255-314 electron/…/lndProxyServer.ts• L390-396 electron/…/litdProxyServer.ts• L14-36 electron/…/tapdProxyServer.ts• L15-37 electron/appIpcListener.ts• L50-59 electron/windowManager.ts• L84-85

LND service proxy

The LND service proxy exposes the core Lightning node actions used by the application. It supports node information and wallet state, peer and channel management, invoice work, payment work, wallet setup, and channel-event subscriptions.

The renderer-side LND client is the application-facing entry point for these actions. The higher Lightning service uses it to turn raw LND responses into application-level node, channel, invoice, and payment data.

References: electron/…/lndProxyServer.ts• L54-192 electron/…/lndProxyServer.ts• L195-215 electron/…/lndProxyServer.ts• L316-353 src/…/lndProxyClient.ts• L15-139 src/…/lndService.ts• L11-23

LND action groups

The LND proxy maps IPC actions to a focused set of backend capabilities:

CapabilityApplication purpose
Node and wallet stateShow node identity, sync state, and wallet balance
Peer actionsList peers and connect a node to another peer
Channel actionsOpen, close, inspect, and list active or pending channels
Invoice actionsCreate, decode, and pay Lightning invoices
Wallet setupRead wallet state, generate a seed, initialize a wallet, and unlock a wallet
Event subscriptionReport channel open, pending, and close changes to the application

Payment calls resolve only after the backend reports success. A failed or ended payment stream becomes an error instead of a successful application result. Channel event streams use the renderer callback path so the UI can react without polling.

References: electron/…/lndProxyServer.ts• L71-192 electron/…/lndProxyServer.ts• L316-353 src/…/lndProxyClient.ts• L25-139 src/…/lndService.ts• L175-206 src/…/lndService.ts• L243-264

LND wallet setup

The wallet setup path uses a separate access level from normal Lightning actions. Before the wallet is ready, the proxy can query state, generate a seed, initialize a wallet, or unlock it through TLS-only RPC clients. After initialization or unlock, it evicts all LND clients so later calls use the node's new RPC connection.

Wallet seed and setup results are treated as sensitive. The IPC channel list marks these actions for redacted logging, so the proxy does not write their values to the debug log.

References: electron/…/lndProxyServer.ts• L255-314 electron/…/lndProxyServer.ts• L346-385 src/…/ipcChannels.ts• L57-60

Litd service proxy

The Litd service proxy exposes Litd status and session management. A session represents a remote access relationship that can provide a selected Litd capability, such as read-only or administrative access, for a limited time.

The proxy connects to Litd's web endpoint with Litd credentials. The application-facing service maps backend session records into the simpler session model used by the UI and checks sub-server status while a Litd node starts.

References: electron/…/litdProxyServer.ts• L24-65 electron/…/litdProxyServer.ts• L71-78 src/…/litdProxyClient.ts• L6-32 src/…/litdService.ts• L8-16 src/…/litdService.ts• L18-66

Litd session lifecycle

The session path has a small set of actions:

  • Status checks show whether Litd sub-servers are running.
  • Session listing returns the current sessions.
  • Session creation requests a label, access type, expiry, and optional mailbox server.
  • Session revocation removes access by the local public key.

The service waits for all enabled Litd sub-servers to report as running before it treats the node as ready. A sub-server that reports an error or remains stopped causes the readiness wait to fail or time out.

References: electron/…/litdProxyServer.ts• L39-65 src/…/litdService.ts• L18-66

Tapd service proxy

The Tapd service proxy exposes Taproot Assets operations and the Lightning actions needed to move those assets. It gives the application one path for asset state, addresses, minting, transfers, Universe sync, and asset-channel payments.

The renderer-side Tapd client forwards typed requests to the main process. The Tapd service then maps backend asset and payment records into application models, while the main-process proxy handles the authenticated local Tapd connection.

References: electron/…/tapdProxyServer.ts• L25-165 electron/…/tapdProxyServer.ts• L171-187 src/…/tapdProxyClient.ts• L6-87 src/…/tapdService.ts• L10-37

Tapd capability groups

The Tapd proxy groups its actions around the asset lifecycle and its supporting network:

CapabilityApplication purpose
Asset stateList assets and balances
Asset creationMint an asset and finalize its mint batch
AddressesCreate and decode Taproot Asset addresses
TransfersSend assets and inspect the resulting transfer
Universe dataRead roots and leaves and sync with a Universe host
Asset channelsFund channels, create asset invoices, and send asset payments

Asset payments are stream-based at the backend boundary. The proxy tracks the accepted sell order and returns the final payment result only when the payment succeeds. A failed payment or a stream that ends without a result becomes an error.

References: electron/…/tapdProxyServer.ts• L40-165 src/…/tapdProxyClient.ts• L13-87 src/…/tapdService.ts• L60-193

General HTTP proxy

The general HTTP proxy gives the application a main-process path for local HTTP APIs that do not use a dedicated service proxy. The Eclair client uses it to send form-encoded requests to an Eclair REST endpoint while keeping the request inside the same Electron IPC boundary.

The proxy supports the common HTTP methods used by the application. It encodes request fields as form data, sends the request through the Node HTTP client, and parses the response as JSON. The app IPC listener exposes this path under the general http channel.

References: electron/httpProxy.ts• L4-40 electron/appIpcListener.ts• L61-73 src/…/eclairApi.ts• L8-34

HTTP request contract

The HTTP path expects a URL, an HTTP method, request headers, and an optional object body. Eclair supplies basic authentication and the form content type before the request reaches the main process. The response must be JSON for the proxy to return it to the caller.

References: electron/httpProxy.ts• L18-39 src/…/eclairApi.ts• L19-34

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep each renderer proxy client's service prefix aligned with the request and response prefixes registered by its main-process proxy.
  • Keep every new or renamed action aligned across src/…/ipcChannels.ts, the renderer client, and the main-process listener map.
  • Preserve the node credential and port contract when node types or local endpoint fields change.
  • Update the matching default-value and binary-value handling when a backend response shape changes.
  • Keep cache clearing connected to node replacement, window reload, app-level cache requests, and LND wallet RPC restarts.
  • Preserve the completion rule for stream-backed payments and channel events when backend stream behavior changes.
  • Keep wallet setup channels redacted when adding or renaming sensitive LND actions.

Important failure modes

TriggerConsequenceGuard
A proxy channel name differs between the renderer client and main listenerThe request receives no matching backend actionKeep the shared channel definition and both sides of the proxy mapping in sync
A node's port, certificate, or macaroon path is staleThe proxy cannot connect to the local nodeClear the service caches after node or window state changes and after LND wallet RPC restarts
An LND or Tapd payment stream ends before a final resultThe caller receives a rejected request instead of a false successTreat only an explicit successful payment result as completion
Litd has an enabled sub-server that is not runningNode readiness never completes or reports the sub-server errorCheck sub-server status before using Litd features
Wallet setup data is written to debug logsSeed or wallet details can leak through logsKeep wallet setup channels in the redacted channel set
A backend response omits empty fields or contains binary valuesThe renderer receives an incomplete or non-serializable modelApply service defaults and convert binary values before replying
The HTTP endpoint returns non-JSON dataThe general HTTP request fails while parsing the responseUse the HTTP proxy only with JSON-returning local API endpoints

Key files

FileWhy to read it
electron/windowManager.tsShows when the service proxies start and how channel events return to the renderer
electron/appIpcListener.tsShows the general app IPC route and shared cache clearing
src/…/ipcService.tsDefines request, response, unique reply, and stream behavior for renderer clients
src/…/ipcChannels.tsDefines the shared action names for app, LND, Litd, and Tapd paths
electron/…/lndProxyServer.tsShows the LND node connection boundary, wallet setup access, and Lightning action routing
electron/…/litdProxyServer.tsShows Litd status and session routing
electron/…/tapdProxyServer.tsShows Tapd asset, Universe, and asset-channel routing
electron/httpProxy.tsShows the general local HTTP request path
src/…/lndProxyClient.tsShows the renderer-facing LND client, wallet setup calls, and event subscription path
src/…/litdProxyClient.tsShows the renderer-facing Litd session client
src/…/tapdProxyClient.tsShows the renderer-facing Tapd capability client