THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Lightning Network Explained: Channels, Invoices, and Settlement

permalink THAMER
#bitcoin-lightning-network#bitcoin-scaling#bolt#off-chain-payments#payment-channels

The Lightning Network is a network of Bitcoin payment channels that lets participants make payments without publishing every intermediate transfer to the Bitcoin blockchain. Bitcoin remains the settlement layer: channel funding and cooperative or unilateral channel closing involve on-chain transactions.

Why does Lightning exist?

Bitcoin blocks have limited capacity, and an on-chain payment must compete for block space. Lightning shifts repeated transfers between channel participants off-chain while relying on Bitcoin transactions and scripts to enforce the latest valid channel state. This can make small, frequent payments practical, but it adds requirements for liquidity, channel management, and monitoring.

Opening a channel

Two peers negotiate a channel and fund a Bitcoin output. Modern channels commonly use a 2-of-2 funding arrangement, so neither party can spend the funding output alone under normal cooperative operation. Before relying on the channel, they exchange commitment transactions that define how the funds can be recovered if the relationship breaks down.

A channel's usable outbound capacity is not the same as its total capacity. The distribution of balances between the peers determines how much each can send. A node also needs inbound liquidity to receive through a route.

Paying over Lightning

A recipient may issue a BOLT 11 invoice containing payment information, an amount when specified, and an expiry. The payer finds a route through channels and attempts the payment. Intermediaries forward conditionally locked transfers; they do not need to know the payer's complete business context to forward a payment.

A Lightning payment is not simply an ordinary Bitcoin transaction broadcast faster. Its settlement and failure behavior depends on channel states, routing, liquidity, and protocol timeouts.

What happens when a channel closes?

A cooperative close publishes an agreed settlement transaction. If cooperation fails, a participant can broadcast an enforceable commitment transaction, subject to the relevant channel rules and timelocks. Nodes must monitor the chain or use appropriate monitoring arrangements to react to potentially outdated states.

Developer considerations

For wallet or service integrations, distinguish invoice creation, payment attempts, settled payments, failed attempts, and channel lifecycle events. Never equate an accepted request with a completed payment. Track payment hashes or other protocol identifiers for idempotency, and test liquidity failures, invoice expiry, fee limits, and disconnects on a controlled network.

Primary references

Lightning Network specifications (BOLTs): https://github.com/lightning/bolts

Lightning Network paper: https://lightning.network/lightning-network-paper.pdf

Bitcoin developer documentation: https://developer.bitcoin.org/

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects