Disclaimer: This is an advanced topic. I strongly suggest you read all previous Bitcoin articles and make sure you understand them.

A Digital Storm

Until now you should have a pretty good understanding of how Bitcoin works. However, we have only considered regular transactions. Is it somehow possible to use Bitcoin in a subscription model? We have learned that transactions are anonymous and definite and can not be reverted, so this seems to make subscriptions complicated. Both parties need a solution to ensure one is not going to cheat the other: by either paying and not receiving the product, or delivering the product and not getting paid. In addition, subscriptions could require a whole lot of many tiny payments, which would inevitably lead to bloating the Blockchain with unnecessary transactions. What if the transaction amount itself is smaller than the transaction fee (i.e. a microtransaction)?
The lightning network solves all these problems. The way it works is as follows:

Imagine two parties – Alice and Bob. Alice pays Bob for a continuous delivery of a service, such as tutoring. Bob wants 1 μBTC (0.001 BTC) for each teaching session. The total amount of planned sessions are 100. Alice does not want to pay 100 μBTC upfront and then hope that Bob will not disappear with them. In addition, she does not want to make a transaction for each session, since every time the transaction fees would be as high as the lesson price itself.. She would have to pay 1 μBTC for the lessons and 1 μBTC for fees, thus spending a total of 200 μBTC.
This is what they do:

Lightning Network1. Alice and Bob both supply a public key to each other and establish a common multisig address. Any transaction from this address would require a signature from both parties.
2. Alice creates a valid transaction that sends 100 μBTC to the multisig address. She does not send this transaction on the BTC network yet.
3. She creates a second transaction, which uses the one from step 2 as input, sending all 100 μBTC back to herself. The earliest spending date is set to some point in the future, such as 100 days after the current date.
4. Alice provides the second transaction to Bob, asking him to sign it. Since it requires the signatures from both parties, it will be used as a backup transaction, in case Bob suddenly disappears, or refuses to provide teaching lessons. Alice can not cheat Bob and just send the BTC back to herself, since the transaction can only be used after 100 days have passed.
5. Alice sends the transaction from step 2 on the BTC network. There are now 100 μBTC on the multisig address.
6. Alice creates a transaction, which uses the 100 μBTC as input and sends 99 μBTC back to herself and 1 μBTC to Bob. She signs the transaction with her private key and sends it over to Bob (e.g. via e-mail, but NOT on the BTC network).
7. Bob has a transaction, which he can sign and redeem at any time. Again, it will send 1 μBTC to him and 99 μBTC to Alice from their common multisig address. This is the payment for the first teaching session. Bob does not need to redeem this signature, except he has a reason not to trust Alice anymore.
8. After the first teaching session, Alice repeats step 6, except this time it sends 98 μBTC back to herself and 2 μBTC to Bob. Again she signs and sends it to Bob off-Bitcoin network.
9. Bob now has a transaction, which he can redeem at any time by signing it. This is the payment for the first and second session. The previous transaction he received becomes obsolete.
10. These steps repeat again and again for every new tutoring session. Each time the amount sent to Alice decreases, while the one being sent to Bob increases.
11. After the last teaching session, Bob will be able to send all 100 μBTC to himself. If he decides to stop providing lessons to Alice prematurely, he can simply redeem the last transaction he received from her. Of course this will also send some μBTC back to her. He needs to do this before 100 days have elapsed or Alice may simply send all 100 μBTC to herself, since the backup transaction will become usable.

 

The advantages of this are:
1. All microtransactions are handled off the Bitcoin network, resulting in less network overhead.
2. Instead of bloating the Blockchain with 100 transactions (1 for every teaching session), there will be only two transactions on the Blockchain – the initial from step 2 and the final from step 11.
3. Less/smaller transaction fees, which in this case are as high as the transferred amount itself!
4. No third parties required.
5. No modifications to the Bitcoin protocol required.

Quite amazing, right?
This covered the most important details about the lightning network and Bitcoin based subscriptions.

- Back to top -