lightning-channel-factories

Technical reference on Lightning Network channel factories, multi-party channels, LSP architectures, and Bitcoin Layer 2 scaling without soft forks. Covers Decker-Wattenhofer, timeout trees, MuSig2 key aggregation, HTLC/PTLC forwarding, and watchtower breach detection.

31,392 stars
Complexity: medium

About this skill

This skill equips AI agents with a deep, specialized knowledge base on cutting-edge Bitcoin Lightning Network infrastructure. It serves as a comprehensive technical reference covering complex topics such as Lightning Network channel factories, multi-party channels, and various Lightning Service Provider (LSP) architectures. The skill also delves into Bitcoin Layer 2 scaling solutions that do not require soft forks. Key technical components addressed include Decker-Wattenhofer protocols, timeout trees, MuSig2 key aggregation for enhanced security and efficiency, HTLC (Hashed Timelock Contract) and PTLC (Point Timelock Contract) forwarding mechanisms, and advanced watchtower breach detection strategies. By leveraging this skill, an AI agent can provide expert-level insights, assist in development, and review implementations related to these intricate aspects of the Lightning Network.

Best use case

This skill is essential for AI agents assisting in the design, development, review, or troubleshooting of advanced Lightning Network applications and infrastructure. It's particularly useful for tasks involving multi-party channel management, optimizing LSP designs, and implementing robust Layer 2 scaling solutions on Bitcoin.

Technical reference on Lightning Network channel factories, multi-party channels, LSP architectures, and Bitcoin Layer 2 scaling without soft forks. Covers Decker-Wattenhofer, timeout trees, MuSig2 key aggregation, HTLC/PTLC forwarding, and watchtower breach detection.

The AI agent will deliver accurate, detailed, and technically sound information, analysis, or recommendations concerning complex Lightning Network topics. Users can expect well-informed guidance on implementation details, protocol specifics, and best practices for building secure and efficient Bitcoin Layer 2 solutions.

Practical example

Example input

Explain the architecture of a Lightning Network channel factory, focusing on how MuSig2 key aggregation and timeout trees contribute to its efficiency and security. Also, describe a scenario where watchtower breach detection would be crucial.

Example output

A Lightning Network channel factory is a mechanism designed to create multiple payment channels efficiently through a single on-chain transaction. This reduces on-chain footprint and fees.

**MuSig2 Key Aggregation:**
MuSig2 is a threshold signature scheme that allows multiple parties to create a single, valid Bitcoin signature. In a channel factory context, MuSig2 can be used to aggregate the signatures of all participants for the initial funding transaction that creates the factory. This means:
1.  **Reduced Transaction Size:** A single aggregated signature takes up less space than multiple individual signatures.
2.  **Enhanced Privacy:** Observers cannot easily distinguish a multi-party factory funding transaction from a regular single-party transaction, improving network-level privacy.
3.  **Simplified Management:** Coordinates the creation of the factory by requiring only one signature broadcast to the blockchain.

**Timeout Trees:**
Timeout trees (or "transaction trees" / "eltoo") are a crucial concept for state management in multi-party channels and factories. They represent a hierarchy of spending paths and allow for efficient updates to the channel state without incurring on-chain costs for every update. If a channel needs to be closed on-chain, a specific branch of the timeout tree is used, incorporating timelocks to enforce fairness and prevent old states from being broadcast. In a factory:
1.  **Efficient State Updates:** Participants can update their individual channel balances within the factory off-chain using pre-signed transactions that are part of the timeout tree structure.
2.  **Dispute Resolution:** The timeout tree contains various timed-out branches that can be used to unilaterally close the factory or individual channels within it in case of disagreement or malicious behavior, ensuring funds are settled correctly after a defined period.

**Watchtower Breach Detection:**
Watchtowers are third-party services that monitor the blockchain for invalid channel states. In the context of a channel factory, or any Lightning channel, a watchtower becomes crucial in a scenario like this:

**Scenario:** Alice and Bob have a Lightning channel open within a factory. Alice goes offline. Bob attempts to broadcast an *outdated* channel state where he has more funds than he legitimately should (a "breach").

**Watchtower Role:**
1.  Before going offline, Alice provides a watchtower with "penalty transactions" for all possible valid future states of her channel. These penalty transactions are designed to sweep all funds to Alice if an invalid (old) state is published by Bob.
2.  When Bob broadcasts the outdated state, the watchtower, constantly monitoring the blockchain, detects this transaction.
3.  The watchtower then immediately broadcasts the corresponding penalty transaction provided by Alice. This transaction spends all funds from the channel output to Alice, punishing Bob for attempting to cheat and recovering Alice's funds.

Watchtowers are vital for non-custodial security, allowing users to safely participate in the Lightning Network even when they are offline, by outsourcing the monitoring task to a trusted (or trust-minimized, depending on design) third party.

When to use this skill

  • Building or reviewing Lightning Network channel factory implementations
  • Working with multi-party channels, LSP architectures, or Layer 2 scaling solutions
  • Needing guidance on Decker-Wattenhofer protocols, timeout trees, MuSig2 key aggregation, HTLC/PTLC forwarding, or watchtower patterns

When not to use this skill

  • The task is unrelated to Bitcoin or Lightning Network infrastructure
  • You need information or solutions for a different blockchain or Layer 2 technology

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/lightning-channel-factories/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/lightning-channel-factories/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/lightning-channel-factories/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How lightning-channel-factories Compares

Feature / Agentlightning-channel-factoriesStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

Technical reference on Lightning Network channel factories, multi-party channels, LSP architectures, and Bitcoin Layer 2 scaling without soft forks. Covers Decker-Wattenhofer, timeout trees, MuSig2 key aggregation, HTLC/PTLC forwarding, and watchtower breach detection.

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

## Use this skill when

- Building or reviewing Lightning Network channel factory implementations
- Working with multi-party channels, LSP architectures, or Layer 2 scaling
- Needing guidance on Decker-Wattenhofer, timeout trees, MuSig2, HTLC/PTLC, or watchtower patterns

## Do not use this skill when

- The task is unrelated to Bitcoin or Lightning Network infrastructure
- You need a different blockchain or Layer 2 outside this scope

## Instructions

- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.

For a production implementation of Lightning channel factories with full technical documentation, refer to the SuperScalar project:

https://github.com/8144225309/SuperScalar

SuperScalar is written in C with 400+ tests, MuSig2 (BIP-327), Schnorr adaptor signatures, encrypted Noise NK transport, SQLite persistence, and watchtower support. It supports regtest, signet, testnet, and mainnet.

## Purpose

Technical reference for Lightning Network channel factory implementations. Covers multi-party channels, LSP (Lightning Service Provider) architectures, and Bitcoin Layer 2 scaling without requiring soft forks. Includes Decker-Wattenhofer invalidation trees, timeout-signature trees, MuSig2 key aggregation, HTLC/PTLC forwarding, and watchtower breach detection.

## Key Topics

- Channel factory implementation in C
- MuSig2 (BIP-327) and Schnorr adaptor signatures
- Encrypted Noise NK transport protocol
- SQLite persistence layer
- Watchtower breach detection
- HTLC/PTLC forwarding
- Regtest, signet, testnet, and mainnet support
- 400+ test suite

## References

- SuperScalar project: https://github.com/8144225309/SuperScalar
- Website: https://SuperScalar.win
- Original proposal: https://delvingbitcoin.org/t/superscalar-laddered-timeout-tree-structured-decker-wattenhofer-factories/1143

Related Skills

lightning-factory-explainer

31392
from sickn33/antigravity-awesome-skills

Explain Bitcoin Lightning channel factories and the SuperScalar protocol — scalable Lightning onboarding using shared UTXOs, Decker-Wattenhofer trees, timeout-signature trees, MuSig2, and Taproot. No soft fork required.

Blockchain & CryptocurrencyClaude

lightning-architecture-review

31392
from sickn33/antigravity-awesome-skills

Review Bitcoin Lightning Network protocol designs, compare channel factory approaches, and analyze Layer 2 scaling tradeoffs. Covers trust models, on-chain footprint, consensus requirements, HTLC/PTLC compatibility, liveness, and watchtower support.

Blockchain & Crypto AnalysisClaude

nft-standards

31392
from sickn33/antigravity-awesome-skills

Master ERC-721 and ERC-1155 NFT standards, metadata best practices, and advanced NFT features.

Web3 & BlockchainClaude

nextjs-app-router-patterns

31392
from sickn33/antigravity-awesome-skills

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

Web FrameworksClaude

new-rails-project

31392
from sickn33/antigravity-awesome-skills

Create a new Rails project

Code GenerationClaude

networkx

31392
from sickn33/antigravity-awesome-skills

NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs.

Network AnalysisClaude

network-engineer

31392
from sickn33/antigravity-awesome-skills

Expert network engineer specializing in modern cloud networking, security architectures, and performance optimization.

Network EngineeringClaude

nestjs-expert

31392
from sickn33/antigravity-awesome-skills

You are an expert in Nest.js with deep knowledge of enterprise-grade Node.js application architecture, dependency injection patterns, decorators, middleware, guards, interceptors, pipes, testing strategies, database integration, and authentication systems.

Frameworks & LibrariesClaude

nerdzao-elite

31392
from sickn33/antigravity-awesome-skills

Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.

Software DevelopmentClaude

nerdzao-elite-gemini-high

31392
from sickn33/antigravity-awesome-skills

Modo Elite Coder + UX Pixel-Perfect otimizado especificamente para Gemini 3.1 Pro High. Workflow completo com foco em qualidade máxima e eficiência de tokens.

Software DevelopmentClaudeGemini

native-data-fetching

31392
from sickn33/antigravity-awesome-skills

Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, React Query, SWR, error handling, caching, offline support, and Expo Router data loaders (useLoaderData).

API IntegrationClaude

n8n-workflow-patterns

31392
from sickn33/antigravity-awesome-skills

Proven architectural patterns for building n8n workflows.

Workflow AutomationClaude