Lightning Network Cheatsheet

Raj Saraogi
6 min readJan 8, 2022

--

Channel Capacity
The total amount of lightning bitcoin locked in a payment channel upon channel opening. Also the sum of your sending and receiving capacity within that channel. This preset balance is the amount that you can transact with and is divided between participants in the channel as long as the channel is open.

Sending/Outbound Capacity
Your sending capacity is the funds you own and can spend within this channel, also known as your local balance or outbound capacity.

Receiving/Inbound Capacity.
Your receiving capacity is the funds your counterparty owns and can spend within this channel, also known as your remote balance or inbound capacity.

Noise Protocol Framework.
All communication between peers is sent via messages called Lightning messages. These messages are all encrypted, using a cryptographic communications framework called the Noise Protocol Framework.

Basis of Lightning Technology (BOLT).
Lightning the standard is defined by a series of standards documents called Basis of Lightning Technology (BOLT), found at the lightning-rfc.

Pathfinding.
The process of finding a path from source to destination is called pathfinding.

Routing.
The process of using that path to make the payment is called routing.

Simplified Payment Verification (SPV).
It can verify payments without needing to download the entire blockchain. It is often used for Bitcoin wallet apps on smartphones by using special SPV nodes that act as an intermediary between the app and a mining node.

Hot wallets.
The funds you store in a Lightning wallet are online all the time. This makes them vulnerable. Hence, you should not store large amounts in a Lightning wallet. Large amounts should be kept in a cold wallet that is not online and which can transact only on-chain.

Sweep Funds.
If your Lightning wallet balance becomes too large for your risk tolerance, you will need to “sweep” funds out of the wallet.

On-Chain Sweep.
Sweeping funds on-chain is accomplished by moving the funds from the Lightning wallet to a Bitcoin wallet. You do that by closing channels. When you close a channel, all funds from your local balance are “swept” to a Bitcoin address.

Off-Chain Sweep.
A second Lightning node that is not advertised on the network. You can establish large capacity channels from your public node (e.g. the one running your shop) to your unadvertised (hidden) node. On a regular basis, “sweep” funds by making a Lightning payment to your hidden node.

Submarine swap.
A node operator can initiate a submarine swap and send all available channel balances to the other party who will send them as a result of on-chain bitcoin in exchange.
The advantage of a submarine swap for sweeping funds is that no channel needs to be closed. That means that we preserve our channels, only re-balancing our channels through this operation. As we send a Lightning payment out, we shift some balance from local to remote on one or more of our channels. Not only does that reduce the balance exposed in our node’s hot wallet, it also increases the balance available for future incoming payments.

Loop In. (LND)
It accepts a Bitcoin on-chain payment and converts it into a Lightning off-chain payment.

Loop Out.(LND)
It converts a Lightning payment into a Bitcoin payment.

Watchtowers.(LND)
They are a mechanism for outsourcing the monitoring and penalty resolution of Lightning protocol violations.

Multi-path payments.
Lightning now supports multi-path payments, you can split your initial funds into several channels and route bigger payments by combining their capacity. At the same time, avoid making your channels too small.

Circular route.
that sends a payment from your node back to your node, via the Lightning Network. By sending a payment out on a channel with large local capacity and arranging the path so that it returns to your node on a channel with large remote capacity, both of those channels will become more balanced.

Routing fees.
Are set by two parameters on each channel: a fixed base fee that is charged for any payment and an additional variable fee rate that is proportional to the payment amount.

Network Connection Layer.
This contains the protocols that interact directly with the internet core protocols (TCP/IP), overlay protocols (Tor v2/v3), and internet services (DNS). This layer also contains the cryptographic transport protocols that protect Lightning messages.

Messaging Layer.
This layer contains the protocols that nodes use to negotiate features, format messages, and encode message fields.

Peer-2-Peer (P2P) Layer.
This layer is the primary protocol layer for communication between Lightning nodes and contains all the different messages exchanged between nodes.

Routing Layer.
This layer contains the protocols used to route payments between nodes, end-to-end and atomically. This layer contains the “core” functionality of the Lightning Network: routed payments.

Payment Layer.
The highest layer of the network, which presents a reliable payment interface to applications.

Pre-signed Bitcoin.
It's like a post-dated check (or cheque), one that can be “cashed” at any time. Unlike the traditional banking system, however, this transaction is not a “promise” of payment (also known as an IOU), but a verifiable bearer instrument that is equivalent to cash. So long as the bitcoin referenced in the transaction has not already been spent at the time of redemption (or at the time you try to “cash” the cheque), the Bitcoin system guarantees that this pre-signed transaction can be broadcast and recorded at any time.

Bitcoin Ownership.
In Bitcoin “ownership” of bitcoin can be defined as the ability to spend that bitcoin.When someone says they “own” bitcoin they typically mean that they know the private key of a Bitcoin address that has some unspent transaction outputs. The private key allows them to sign a transaction to spend that bitcoin by transferring it to a different address.
“Your keys, your coins — not your keys, not your coins”

Multisignature scripts.
The Bitcoin scripting language provides a multisignature building block (primitive), that can be used to build escrow services and complex ownership configurations between several stakeholders. An arrangement that requires multiple signatures to spend Bitcoin is called a multisignature scheme, further specified as an K-of-N scheme, where:

  • N is the total number of signers identified in the multisignature scheme, and
  • K is the quorum or threshold — the minimum number of signatures to authorize spending.
  • The Lightning Network uses a 2-of-2 multisignature scheme to build a payment channel.

Payment channels in Lightning are based on a 2-of-2 multisig address, with the two channel partners as signers in the multisig. At this time, channels are funded only by one of the two channel partners: When you choose to “open” a channel you deposit funds into the 2-of-2 multisig address with a transaction. Once that transaction is mined and the funds are in the multisig, you can’t get them back without cooperation from your channel partner, because you need their signature (also) to spend the 2-of-2.

Private And Public Key.
Each node generates a root private key when first initialized. The private key is kept private at all times (never shared) and securely stored in the node’s wallet. From that private key, the node derives a public key which is the node identifier and shared with the network. Since the key space is enormous, as long as each node generates the private key randomly, it will have a unique public key, which can therefore uniquely identify it on the network.

Node network address.
Every node also advertises a network address where it can be reached, in one of several possible formats:
TCP/IP : An IPv4 or IPv6 address and TCP port number
TCP/Tor :A Tor “onion” address and TCP port number
The network address identifier is written as Address:Port

Node identifiers.
Together the node public key and network address are written in the following format, separated by an @ sign, as NodeID@Address:Port.
The identifier above is often encoded in a QR code, making it easier for users to scan.
To open a payment channel, two nodes must first be connected as direct peers by opening a connection over the internet (or Tor).

Message protocol.
Which establishes how the Lightning Nodes communicate over the internet and what messages they exchange with each other.

Cryptographic protocol.
Which establishes how the two nodes construct and sign Bitcoin transactions. Lightning Peer Protocol for Channel Management, and the cryptographic protocol that they use to build Bitcoin transactions.

--

--

Raj Saraogi
Raj Saraogi

Written by Raj Saraogi

A “mediocre” programmer with `curiosity` inherited.

No responses yet