For those who may not know the context, this has to do with long-term scaling of the Bitcoin network. The very first public response to Satoshi's announcement of Bitcoin was an expression of doubt about scalability: We very, very much need such a system, but the way I understand your proposal, it does not seem to scale to the required size. ... To detect and reject a double spending event in a timely manner, one must…
> Each one represents a kind of private ledger. That is an interesting quote. So, without the blockchain, how does Lightning track which transactions have been completed?
The main security problem to solve is preventing one party from publishing a previous channel state (half-signed transaction) giving themselves more money than they actually have by rights.
For example, Alice and Bob might start with a channel giving each of them 5 bitcoin. Then Alice makes two one-bitcoin payments to Bob:
A | B
------
4 | 6
3 | 7
Alice decides she wants to take back her last payment and instead publish the earlier transaction (signed by Bob) giving herself 4 bitcoin rather than the one giving herself 3.
This problem is solved with hashed timelock contracts (HTLCs). Without getting too technical, HTLCs make it possible for a party who spots a counterparty attempting to publish an invalid transaction to take all of the money in the channel (i.e., Bob would take all 10 bitcoin). The main idea is that cryptographic hash functions are one-way. If I make a payment contingent on knowing a preimage to a hash value, I can cause the payment to become valid by revealing the preimage.
Along with the signature to a transaction, Alice must also give Bob the preimage for the previous transaction before he will accept it. When she does, Bob knows that if Alice tries to play games, he can take all of her money.
This video gives a high-level overview: