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 / lightning-connections-and-payments

Lightning connections and payments

Lightning workflows in the network designer help an engineer connect to a running Lightning node, form channels between nodes, and move funds with invoices. The selected node exposes connection data and actions through one detail card. The wider canvas model is described in Network designer experience.

Connection credentials and sessions

The connection view gives external tools the endpoints and credentials needed to use the selected node. It adapts to the node implementation, while the action view exposes payment and channel work only when the node can perform live operations.

The main connection flow is:

flowchart LR
    Select[Select Lightning node] --> Detail[Open node details]
    Detail --> Connect[Open Connect tab]
    Connect --> Endpoints[Copy API and peer endpoints]
    Connect --> Credentials[Choose available credential format]
    Credentials --> External[Use credentials in an external client]
    Detail --> Actions[Open Actions tab]
    Actions --> Channel[Open channel or create and pay invoice]

Node connection information

The Connect tab shows copyable REST, gRPC, and Lightning peer-to-peer addresses when the node has usable connection state. It also links to the matching API documentation. litd adds its web address and web password because it provides a web-facing service in addition to the Lightning APIs.

The available credential forms match the node implementation. LND and litd expose TLS and macaroon data. c-lightning exposes TLS and rune data. Eclair exposes Basic Auth. The designer can show file paths or encoded values when the node supports those forms.

LND has two wallet states that affect connection access. A locked wallet still exposes its connection details and macaroon choices. A wallet that has not been created exposes only the TLS certificate path until initialization creates the other credentials. If the wallet state cannot be read, the designer shows an error and does not guess which credential flow is safe.

References: src/…/ConnectTab.tsx• L61-85 src/…/ConnectTab.tsx• L106-138 src/…/ConnectTab.tsx• L139-194 src/…/ConnectTab.spec.tsx• L27-117

LND connection URLs

LND nodes provide an LND Connect view that turns the local host, API port, TLS certificate, and selected macaroon into copyable gRPC and REST URLs. The available forms separate admin, invoice, and read-only access so an external client can receive only the access level it needs.

References: src/…/ConnectTab.tsx• L293-299 src/…/LndConnect.tsx• L16-59 src/…/EncodedStrings.tsx• L16-53

litd pairing sessions

litd sessions provide time-limited credentials for paired clients. The Connect tab lists sessions by label and state, and it lets an engineer create, inspect, and revoke them without leaving the selected node.

Session creation supports Admin or Read Only access, an expiry date, and an optional mailbox server. After creation, the designer shows a one-time pairing phrase for the client. Session details include the identity, pairing, mailbox, state, account, key, and time data. Revocation updates the list so the displayed state matches the node.

References: src/…/ConnectTab.tsx• L247-325 src/…/LncSessionsList.tsx• L26-80 src/…/LncAddSessionModal.tsx• L25-68 src/…/LncAddSessionModal.tsx• L75-166 src/…/LncSessionDrawer.tsx• L19-97 src/…/LncRevokeButton.tsx• L12-41 src/…/LightningDetails.tsx• L23-40

Peers and channels

A Lightning peer is a node that another Lightning node can reach through its peer address. A channel is the funded relationship that carries Lightning balance between two peers. In the designer, the channel is the meaningful graph relationship; peer preparation supports that relationship rather than appearing as a separate graph link.

Peer preparation

Channel opening needs the destination node's peer address. The network state can prepare Lightning nodes as peers, while a channel request connects the source to the destination when needed. The connection view exposes internal and external peer addresses for use inside or outside the application.

The node public key identifies the peer behind a channel. This lets later channel updates match the live node state to the same graph relationship.

References: src/…/ConnectTab.tsx• L102-105 src/…/ConnectTab.tsx• L230-245 src/…/lightning.ts• L160-185 src/…/lightning.ts• L216-229 src/…/chart.ts• L273-299

Channel opening

The Open Channel action selects a started source node and destination node. It accepts a channel capacity and can fund the source from the network Bitcoin backend when the source lacks enough confirmed funds. A Bitcoin channel can be private or public.

litd-to-litd channels can also carry a Taproot Asset. The form selects the asset and uses its channel balance as the channel capacity. This is the Lightning extension of the asset flow described in TAP asset interactions.

The graph-link flow checks that the network and both nodes are started before it opens the form. After the channel transaction is created, the Bitcoin network confirms it and the nodes process the result before the designer reloads the channel state.

References: src/…/ActionsTab.tsx• L31-41 src/…/OpenChannelButtons.tsx• L20-51 src/…/OpenChannelModal.tsx• L47-98 src/…/OpenChannelModal.tsx• L129-239 src/…/designer.ts• L290-327 src/…/lightning.ts• L205-249

Channel view and closure

A channel link shows the status, capacity, local and remote balances, identifier, privacy, and participating nodes. A pending channel remains visible while confirmation is in progress. An open channel can be closed from its link details when the source node is running.

Channel events and later refreshes keep the graph aligned with node state. A stable channel identifier lets balance changes and closure actions continue to address the same graph relationship.

References: src/…/Channel.tsx• L29-121 src/…/CloseChannelButton.tsx• L14-55 src/…/chart.ts• L218-271 src/…/chart.ts• L273-390 src/…/lightning.ts• L336-377

Invoice creation

An invoice is a payment request made by a receiving Lightning node. The designer lets an engineer choose that node, enter an amount, and copy the encoded invoice for a payer.

Invoice form

The Create Invoice action is available from the Actions tab or the selected node's context menu when the node is started. Bitcoin invoices use satoshis and support an optional memo and expiry. After creation, the modal changes to a result view that keeps the encoded invoice available for copying.

litd nodes can create an invoice for a Taproot Asset held in a Lightning channel. The form shows the asset name and available channel balance. It also shows the Bitcoin amount represented by the invoice so the engineer can relate the asset amount to the Lightning payment.

References: src/…/ActionsTab.tsx• L31-36 src/…/PaymentButtons.tsx• L20-49 src/…/CreateInvoiceModal.tsx• L53-128 src/…/CreateInvoiceModal.tsx• L147-251 src/…/NetworkDesigner.tsx• L54-122

Invoice readiness

Before the asset form lists choices, the designer refreshes the litd node and channel data. An asset invoice needs enough of the chosen asset in a channel on the receiving node. The request then uses the Lightning service for a Bitcoin invoice or the litd asset path for an asset invoice.

References: src/…/CreateInvoiceModal.tsx• L75-87 src/…/lightning.ts• L276-280 src/…/lit.ts• L117-140

Invoice payment

Invoice payment moves funds from a selected paying node to the destination in an encoded invoice. The designer accepts the invoice as input, checks usable outbound liquidity, and reports the paid amount after the backend confirms the payment.

Payment form

The Pay Invoice action is available from the Actions tab or the selected node's context menu when the node is started. The engineer selects Bitcoin or a supported Taproot Asset and pastes the invoice. The payment control remains unavailable when the selected node has no spendable balance for the chosen payment type.

The Bitcoin liquidity check includes channels opened by either side. This matters because a peer-opened channel can still contain spendable balance for the selected payer. Asset payments use the asset balance in a litd channel instead of the Bitcoin-only check.

References: src/…/ActionsTab.tsx• L31-36 src/…/PaymentButtons.tsx• L20-49 src/…/PayInvoiceModal.tsx• L39-137 src/…/PayInvoiceModal.tsx• L139-206

Payment completion

For a Bitcoin invoice, the selected Lightning service sends the payment and returns the received amount. For a litd asset invoice, the designer checks the asset channel, decodes the invoice, and sends the payment through the asset service with a route peer and fee limit.

After payment, the store waits for node processing and refreshes the network graph. The same create-and-pay sequence supports channel-balance workflows: it creates invoices on target nodes and pays them from source nodes to move balance across channels.

References: src/…/lightning.ts• L282-297 src/…/lightning.ts• L450-493 src/…/lit.ts• L143-182

Change checklist

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

  • Keep the displayed connection endpoints and credential modes aligned with each node implementation and wallet state.
  • Keep the LND wallet-state error path separate from the locked-wallet and not-initialized-wallet paths.
  • Keep litd session creation, session detail fields, and list refreshes aligned with the session states accepted by the service.
  • Keep graph channel links and channel identifiers aligned with channel refreshes so pending and confirmed channels do not create stale relationships.
  • Keep channel funding rules aligned with Bitcoin confirmation and the separate Taproot Asset channel path.
  • Keep invoice amount units aligned between displayed values, Lightning satoshis, and Taproot Asset units.
  • Keep payment liquidity checks aligned with both sides of a channel and with the selected payment type.
  • Keep post-payment waits and graph refreshes aligned with backend completion so the designer does not show old balances.

Important failure modes

TriggerConsequenceGuard
A stopped node is opened in the Connect tabNo live endpoint or credential data is shownStart the node before using connection details
The LND wallet state cannot be readThe designer cannot safely choose between locked and not-initialized credential flowsRetry the wallet-state request before using connection credentials
An external client uses the wrong credential form for a backendAuthentication fails even when the endpoint is correctUse the credential mode shown for that node implementation
A litd session expires or is revokedThe paired client can no longer use that sessionCheck the session state and expiry and create a new session when needed
The network or either channel node is stoppedThe channel request cannot produce a usable graph relationshipStart the network and both Lightning nodes first
The source lacks enough confirmed Bitcoin for channel fundingChannel creation fails before the channel is usableEnable automatic funding or provide enough confirmed Bitcoin
The payer has no outbound liquidity for the chosen payment typeThe payment action stays unavailable or the payment failsFund an open channel with spendable Bitcoin or asset balance
An asset invoice has no matching asset channel balanceAsset invoice creation or payment failsSelect an asset held in a suitable litd channel
A channel or payment response is read before nodes process itThe graph shows pending state or old balancesWait for node processing and refresh the designer state

Key files

FileWhy to read it
src/…/LightningDetails.tsxDefines the selected Lightning node's Info, Connect, and Actions views and loads the state needed by those views
src/…/ConnectTab.tsxDefines implementation-specific endpoints, credential modes, wallet-state handling, and litd session access
src/…/ActionsTab.tsxShows which channel, invoice, payment, and asset actions are available for a started node
src/…/LncSessionsList.tsxShows the litd session list and its session-management entry points
src/…/LncAddSessionModal.tsxShows pairing session creation and pairing-phrase access
src/…/LncSessionDrawer.tsxShows session inspection and revocation access
src/…/OpenChannelModal.tsxShows channel selection, funding, privacy, and asset-channel choices
src/…/CreateInvoiceModal.tsxShows Bitcoin and litd asset invoice creation
src/…/PayInvoiceModal.tsxShows payer selection, liquidity checks, invoice input, and payment results
src/…/Channel.tsxShows channel details and the closure action attached to a graph link
src/…/lightning.tsCoordinates peer preparation, channel lifecycle, invoice actions, payment completion, and graph refreshes
src/…/lit.tsCoordinates litd sessions and Taproot Asset invoice paths
src/…/chart.tsMaps channel state into graph links and keeps channel relationships stable