With swaps, let's call the person sending on-chain funds and receiving lightning funds the sender and the person receiving the on-chain funds but sending lightning funds the recipient.
So when I use the term sender and receiver I’m referring to movement of the on-chain funds.
Just like with a lightning payment the person who wants to receive funds over lightning (the on-chain sender in our swaps example) creates a random number called the payment secret or preimage and then uses it to calculate the payment hash.
They construct a tx that has two payment paths:
1. Pays to the receiver’s pubkey only if they know the preimage
2. Pays to sender after a delay
The sender can release the payment to the recipient by providing the preimage OR they can wait for the delay to reclaim their funds.
The sender creates a lightning invoice using the same preimage they used to construct the on-chain tx and gives it to the on-chain recipient to pay.
The stage is set.
When the recipient pays the invoice they will receive the preimage and be able to claim the on-chain funds.
If the recipient fails to pay the invoice then the original sender can just take their money back after the time delay.
Funds are never at risk because the other party must pay the lightning invoice in order to get the secret to claim the onchain funds:
The sender only reveals the preimage after they have received the funds over lightning.
The receiver will receive the preimage if they pay the invoice.
The receiver can compare hashes in the invoice and the on-chain tx to be sure the preimage will unlock the on-chain funds.
This technique is useful to manage the liquidity of your lightning channels.
It’s a great way to get incoming liquidity and for moving any extra funds you might have in lightning back into an on-chain wallet for secure storage without closing the channel.
I hope this helped you understand how submarine swaps work and why you might want to use them. They are a powerful tool for managing your lightning node.
Be sure to follow if you want to continue learning about Bitcoin and the lightning network.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
If you self custody your Bitcoin then you almost certainly have come across a mnemonic phrase of 12 or 24 words.
What is a mnemonic?
Why do I have one?
How does it work?
I’ve been working on Bitcoin for almost a decade, let me break it down for you 👇
A mnemonic is a tool that makes it easier to remember something.
You’ve probably used them in school to help you learn the planets (My Very Easy Method Just Speeds Up Naming Planets) or for biological classification (King Philip Came Over For Good Spaghetti).
So how are mnemonics used in Bitcoin?
They help you remember your private keys by making it easy to write down or even memorize your seed.
Why would it be hard to write down or memorize without a mnemonic?
Without it you’d have to memorize a string of 132 one’s and zero’s
A lot of people think that Bitcoin is “too expensive” for them to get involved. That it’s a tool for the already wealthy. This is not true. You might be wondering:
Do I need to buy a whole coin?
How should I value Bitcoin?
Let me explain a bit about how I think about it 👇
First and foremost, no, you do not need to buy a whole coin.
A Bitcoin is divisible into 100M units called Satoshis (yes, after Satoshi Nakamoto, the pseudonymous creator of Bitcoin).
You can buy ANY amount you’re comfortable with. As little as $0.25 on the @ln_strike app!
There are a million ways people try to value Bitcoin and all of them will give you different results.
I try to stay away from short term price predictions and look at it as more than an investment.
Bitcoin provides a new form of digital money that is native to the internet.
What an exciting week it’s been in Bitcoin. Is it ever boring? Definitely not.
I hope you learned a lot from my educational threads this week.
In no particular order, here’s what I found most important or interesting this week 👇
@adamcurry explains to @joerogan why he believes his money is safer in Bitcoin, why it will be a huge part of our future, and why to stay away from shitcoins.
If you’ve done any research into Bitcoin you’ve heard people talk about private key storage.
What are keys?
What’s the difference between hot and cold storage?
Which should I use?
Keys are one of the most important topics in Bitcoin. Let me break it down for you 👇
To understand keys you need to know a little bit about cryptography.
Keys generally come as a pair of public and private keys.
The most common use of keys is to encrypt and decrypt messages.
However, in Bitcoin they are primarily used to generate and verify signatures.
In order to spend Bitcoin you need to produce a signature by signing every tx you make in order to prove to the network that you control the UTXOs being spent.
You use your private keys to produce this signature.