Payment Channels Fundamentals
A payment channel is like a bar tab between two people. Open the tab once (one blockchain transaction), exchange as many drinks as you want (unlimited off-chain payments), and settle up at the end (one blockchain transaction).
Payment channels are the building blocks of Lightning Network. They allow two parties to transact with each other off-chain while maintaining the security guarantees of Bitcoin.
Channel lifecycle:
1. Channel Opening: Create a 2-of-2 multisig address with funding transaction 2. Channel Updates: Exchange signed transactions off-chain for instant payments 3. Channel Closing: Either party can close by broadcasting latest state 4. Force Closure: If one party goes offline, the other can force close after timeout
Technical components:
- •Commitment Transaction: Shows current channel state
- •Revocation Keys: Prevent old states from being broadcast
- •HTLCs (Hash Time Locked Contracts): Enable multi-hop payments
- •CSV (Check Sequence Verify): Time delays for force closure protection
# Simplified channel state
def channel_state(alice_amount, bob_amount, channel_id):
commitment_tx = create_tx([
{"output": alice_amount, "pubkey": alice_pubkey},
{"output": bob_amount, "pubkey": bob_pubkey}
])
return sign_commitment(commitment_tx, revoke_keys)
# Channel update (payment)
new_state = channel_state(old_alice - payment, old_bob + payment, channel_id)Payment channels compress potentially thousands of transactions into just two on-chain transactions: the opening and the closing. Everything in between happens instantly and privately.
Test Your Knowledge
2 questions · Passing score: 80%
Enjoying these lessons?
Get a free Bitcoin lesson in your inbox every week. Join thousands of learners.
Free forever. No spam. Unsubscribe anytime.