lightning-channels
Lightning channel mechanics: funding tx, commitment tx, anchor outputs, to_local / to_remote outputs, dual-funded (v2), zero-conf, wumbo, taproot channels, splicing. Quick refs: state machine, commitment tx structure, force-close flow. USE WHEN: opening/closing channels, debugging force-closes, designing channel UX, evaluating anchor vs static-remote-key tradeoffs.
What this skill does
# Lightning Channels > **Quick refs**: [state-machine.md](quick-ref/state-machine.md), [commitment-tx.md](quick-ref/commitment-tx.md), [force-close.md](quick-ref/force-close.md) A Lightning channel is a 2-of-2 multisig output on chain that two parties update off-chain via signed **commitment transactions**. Each commitment is a fully-signed tx that, if broadcast, settles the channel in one party's favour at the latest committed state. ## Channel lifecycle 1. **Open** — `open_channel` → `accept_channel` → on-chain funding tx → `funding_locked` (after `min_depth`). 2. **Update** — exchange `update_add_htlc` / `commitment_signed` / `revoke_and_ack` to flow funds. 3. **Close** — cooperative (`shutdown` + `closing_signed`) or unilateral (broadcast latest commitment). ## Funding tx Two-party 2-of-2 multisig (legacy): ``` P2WSH(redeem = MULTI 2 <pk_init> <pk_resp> 2 CHECKMULTISIG) ``` Or Taproot key-aggregated (taproot channels): ``` P2TR(MuSig2(pk_init, pk_resp)) ``` Funding tx flow: - Initiator constructs funding tx, sends `funding_created` with outpoint. - Responder signs initial commitment tx. - Initiator broadcasts funding tx. - Both wait `min_depth` confirmations, then `channel_ready`. ## Commitment tx (current state) Each side holds the **latest** commitment they can broadcast. Outputs: ``` to_local (this party's balance, with revocation OP_CSV delay) to_remote (other party's balance) htlc_offered (one per outgoing HTLC) htlc_received (one per incoming HTLC) to_local_anchor (330 sats, modern anchor format) to_remote_anchor (330 sats) ``` Asymmetric: each party's commitment has its own `to_local` (with revocation key) — the other side has the revocation secret. ## Static remote key (BOLT 9 bit 12) Pre-BOLT static_remotekey: `to_remote` was rotated each commitment update, requiring constant pubkey derivation. Post-BOLT: - `to_remote` is a fixed pubkey for the lifetime of the channel. - Simplifies on-chain recovery (always know your `to_remote` key). ## Anchor outputs (BOLT 9 bit 20/21) Modern anchor commitment: - Each party has a 330-sat `to_local_anchor` output spendable immediately by themselves and after 16 blocks by anyone. - Allows CPFP fee bumping by spending the anchor. - Channel-cost: 660 sats committed to anchors, recovered on close (or claimed by anyone after 16 blocks via the public path). Defeats some pre-anchor pinning attacks but introduced new vulnerabilities (replacement cycling) addressed by TRUC v3. ## Dual-funded (BOLT 2 v2) Both parties contribute inputs to the funding tx → can have non-zero balance for both sides at open time. Messages: - `open_channel2`, `accept_channel2`. - `tx_add_input`, `tx_add_output`, `tx_remove_input`, `tx_complete`. - `tx_signatures` to exchange final input signatures. Use case: liquidity-providing services, side-by-side funding. ## Zero-conf channels (BOLT 9 bit 38) Both parties agree to treat the channel as "open" before the funding tx confirms. Uses `scid_alias` (BOLT 9 bit 40) to give the channel a short channel ID before any block confirmation. Use case: LSPs (JIT channel open during a payment). Risk: if the funder doesn't publish the funding tx (or mempool drops it), receiver loses HTLCs that flowed through. ## Wumbo (BOLT 9 bit 18) Channels > 0.16777216 BTC (the legacy max from `option_support_large_channel`). With wumbo, channels can be arbitrarily large (network-defined limits remain). ## Taproot channels (BOLT 9 bit 56) "Simple Taproot Channels": - Funding output: P2TR with MuSig2-aggregated key. - Commitment scripts: Tapscript leaves. - Improvements: privacy (cooperative spends look like single-sig), smaller witness in cooperative case. Fully cooperative spend = 1 input, 1 sig, key-path spend. ## Splicing (BOLT 2 splice) Modify channel capacity without closing/reopening: - **Splice-in**: add liquidity from on-chain funds. - **Splice-out**: withdraw to on-chain without closing. Atomic: previous channel state continues with new funding output. CLN ships splicing; LND has work-in-progress; LDK partial. ## Closing ### Cooperative `shutdown` exchange with each side's `scriptpubkey`. Then `closing_signed` exchange to negotiate fee. Final tx broadcast — single tx, no CSV delay, no anchors needed. ### Unilateral (force-close) One party broadcasts their latest commitment. Counterparty must: - Wait `to_self_delay` blocks before claiming `to_local`. - Resolve any in-flight HTLCs via 2nd-stage HTLC txs. - If counterparty cheats (broadcasts old commitment), use revocation key within `to_self_delay` to claim entire channel. ## Common bugs - Closing a channel right after open before `min_depth` → expensive, lose anchor sats. - Force-closing when cooperative would have worked → blockchain fees + delay. - Not monitoring chain → missed cheating broadcast → counterparty steals channel. - Anchor outputs without enough on-chain UTXOs to CPFP → fee-bumping impossible, commitment stuck at low rate. - Zero-conf channel with untrusted funder → loss of in-flight payments. ## See also - [htlcs/SKILL.md](../htlcs/SKILL.md) - [splicing/SKILL.md](../splicing/SKILL.md) - [taproot-channels/SKILL.md](../taproot-channels/SKILL.md) - [replacement-cycling/SKILL.md](../replacement-cycling/SKILL.md)
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.