Torq (formerly LN Capital) Profile picture
Empowering Lightning Network enterprises with advanced tools for efficient node management.⚡️#Bitcoin (https://t.co/N9n1NqxofN)

Dec 20, 2022, 13 tweets

The magic of the Lightning Network is built on HTLCs

But most Bitcoiners don't know how they work.

Quick thread:

HTLC stands for “Hash Time-Lock Contract”

In short, HTLCs are programmable smart contracts that create atomic trustless transactions between peers on the Lightning Network.

HTLCs are conditional payments that say “I will pay you [x+1] satoshis if you prove you’ve forwarded [x] satoshis”.

(the +1 would be the routing fee in this scenario)

HTLCs have two main components:

1. The Secret (also called a preimage)
2. The Payment Hash (a SHA-256 hash of the secret)

Here are some visuals to help you understand:

Alice, Bob, Carol, and Dave all have channels with each other.

But how do we ensure that a payment will get from Alice to Dave?

1/

Alice requests an invoice from Dave.

Dave generates a random secret (the preimage), and sends a SHA-256 hash of the secret to Alice (the payment hash).

2/

Alice sends a Hash Time-Lock Contract containing the payment hash to Bob.

3/

Bob creates a new HTLC and forwards it to Carol.

Each HTLC contains the original payment hash, the hash of Dave's secret.

Carol repeats the process, forwarding a new HTLC to Dave.

4/

Dave then reveals the secret to Carol, which unlocks the funds from Carol to Dave.

5/

Carol sends the secret to Bob, then Bob sends it to Alice, unlocking funds along the rest of the chain.

If any disputes arise in this process, the transaction is broadcasted on-chain, and the funds are settled that way.

This settlement mechanism was programmed into the HTLC from the start.

This is what makes Lightning Network trustless.

That’s it!

Now you know what an HTLC is and how they work on LN😄

HTLCs are quite complex, so we had to simplify a lot here. Let us know if you want part 2!

Like & retweet if this was valuable!

Psssst... If you’re running a #LightningNetwork node you should take a look at Torq.

github.com/lncapital/torq

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling