Torq (formerly LN Capital) Profile picture
Dec 20, 2022 13 tweets 4 min read Read on X
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

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Torq (formerly LN Capital)

Torq (formerly LN Capital) Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TorqLN

Sep 24, 2023
One of the biggest problems in Lightning finally has a solution.

CHANNEL JAMMING–

A Hybrid Approach: Image
Firstly, what is channel jamming?

Jamming is a type of denial of service (DDoS) attack on Lightning channels.

The goal of the attack is to make a Lightning channel unusable.
To execute this attack, a malicious actor sets up two nodes and sends payments between them.

However, they don’t release the preimage (the secret number that unlocks funds across the route) for each payment, leaving the payment stuck “in flight”.
Read 30 tweets
Aug 6, 2023
Taproot unlocked the future of #Bitcoin Privacy

But most Bitcoiners have no idea how.

A SCHNORR SIGNATURE THREAD: Image
It’s well known that Bitcoin has a privacy problem.

Tracking UTXOs from KYC exchanges is trivial, and specialized firms like Chainalysis have cropped up for this very purpose.

As Bitcoiners, we should care A LOT about privacy.

It’s a fundamental human right, after all.
So how does Taproot solve part of this problem?
Read 18 tweets
Jul 30, 2023
Every Bitcoiner should understand this graph.

Without it, #Bitcoin would be impossible.

Elliptic Curves thread: Image
Elliptic curve cryptography is a type of cryptography that uses elliptic curves to create mathematically linked public & private keys.
Bitcoin uses a curve called secp256k1, which is defined by the equation y^2=x^3+7.

The points along this curve are used to derive the values of public & private keys. Image
Read 17 tweets
Jul 7, 2023
L402 is the next step in the evolution of the internet.

Metered APIs built on Lightning will revolutionize the machine-to-machine economy.

But how does L402 actually work, on a technical level?

Thread:
In short, L402 is a protocol standard for payment-metered APIs explicitly designed to fit neatly into the existing HTTP 402 Payment Required status response code.
The original HTTP 402 status code was created to enable digital cash or (micro) payment systems and would indicate that the requested content is not available until the client makes a payment.
Read 17 tweets
Jun 30, 2023
Torq's automation features are INCREDIBLY powerful⚡️

Here's how node runners can take full advantage of one of our favorite automations -

THE REBALANCER:
1/

All of Torq's automation flows start with a trigger.

The default rebalancer has two triggers.

One is time based (runs every 30 minutes)

And the second is based on channel balances (it runs every time a channel balance changes)
2/

Next - we need a data source.

In Torq, you can use conditionality on data sources.

The rebalancer can take either ALL your channels, or ONLY the channels that triggered the workflow (i.e, the channel whose balance changed), and execute separate actions on each data set.
Read 14 tweets
Jun 25, 2023
If you’re interested in #Bitcoin & Lightning, it’s critical to understand the concept of a “Preimage”

Bear markets are for learning, right?

Let’s break it down👇 Image
Simply put, a preimage is the data that is input into a hash function to generate a hash. Image
But what does this mean and how does it work in the context of Bitcoin and the Lightning Network?
Read 15 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(