Payment Channels Fundamentals

16 min readinteractiveIncludes quiz · 2 questions

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
Payment Channel Structure
# 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)

Test Your Knowledge

This lesson includes a 2-question quiz (passing score: 80%).

Quiz functionality available in the mobile app.