Lightning Channel Example
Reference implementation of Lightning Channels on Arkade by Vincenzo Palazzo
Design principles
The Server coordinates liquidity. It does not intermediate payments. Channel funding can happen immediately via preconfirmation. Users who find the preconfirmation trust assumption acceptable (typical for smaller channels or trusted counterparties) can begin using channels right away. Users requiring Bitcoin finality wait for the next signing session that creates a Batch. Arkade compresses many previously preconfirmed operations from the Virtual Mempool DAG into a single onchain settlement. Channel opens, closes, and resizes all collapse into a single onchain footprint regardless of how many channel operations the DAG contains. Once a channel exists, Alice and Bob operate it as a standard Lightning channel. Commitment transactions, revocation, and HTLC forwarding follow BOLT specifications. The Server is not involved. The Server re-enters the picture only when the channel’s underlying VTXO approaches Batch expiry or when the parties want to resize, close, or migrate the channel.Channel lifecycle
Funding
Alice and Bob submit an Arkade transaction producing a VTXO with the funding output script. With preconfirmation, the channel is usable immediately. They exchange initial commitment transactions following standard channel establishment.Normal operation
The channel operates as standard Lightning. Alice and Bob exchange commitment transactions, rotate revocation secrets, and forward HTLCs. The Server has no role. Latency and trust properties match vanilla Lightning.Renewal
VTXOs expire at Batch expiry. Before expiry, the channel must migrate into a new Batch output. The simple path: either party submits an Arkade transaction attaching the channel VTXO to a new output. This is non-interactive between channel participants. No quiescence required for basic renewal.Renewal with Bitcoin Finality (Advanced)
Renewal with Bitcoin Finality (Advanced)
For users requiring Bitcoin finality throughout the renewal process. This flow assumes one channel party is an LSP (typical for mobile clients).
- User and LSP quiesce the channel (pause HTLC forwarding).
- They request a new VTXO in the upcoming Batch with identical capacity allocation.
- The Batch settles onchain.
- User and LSP create commitment transactions spending the new funding output with the same balance distribution.
- They sign a forfeit transaction on the old VTXO, revoking the old channel state.
- User and LSP unquiesce and resume operation on the new VTXO.
Resize
Resize follows the renewal pattern with a modified balance allocation. If Alice wants more inbound capacity, the new VTXO reflects that. If Bob wants to withdraw funds, the new VTXO is smaller and Bob receives a separate VTXO for the withdrawn amount.Cooperative close
Alice and Bob sign a settlement transaction spending the channel VTXO directly to their respective destinations. Each party can send an Arkade transaction to their own address, eventually obtaining Bitcoin finality with onchain settlement.Force close
If one channel party becomes uncooperative, the other party cooperates with the Server to execute a force close. The party broadcasts their latest commitment transaction, and resolution proceeds via standard Lightning semantics (to_local delay, HTLC resolution). Unilateral exit (waiting for the Ark CSV timeout to bypass the Server) is the fallback of last resort when the Server disappears.VTXO expiry and HTLC coordination
This is the critical constraint. If an HTLC’s CLTV timeout extends past the VTXO’s Batch expiry, the VTXO becomes unilaterally spendable before the HTLC resolves. This creates a race condition. Rule: Never accept an HTLC whose CLTV timeout exceeds (Batch expiry minus safety margin).Commitment transaction structure
Each commitment transaction contains:| Output | Script | Purpose |
|---|---|---|
| to_local | Revocation + CSV | Broadcaster’s balance |
| to_remote | Immediate | Counterparty’s balance |
| HTLCs | Hashlock + timelock | Pending payments |