Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cauciuc08 on June 16, 2020, 05:49:27 PM



Title: off chain storage for Bitcoin possible?
Post by: cauciuc08 on June 16, 2020, 05:49:27 PM
I wondered if anyone knows more about state channel and off chain storage. We all know that one problem of Bitcoin is scalability.
Off chain storage could be one answer but I don t really understand how that could work.
Has anyone any ideas?


Title: Re: off chain storage for Bitcoin possible?
Post by: Rath_ on June 16, 2020, 06:29:14 PM
Has anyone any ideas?

The Lightning Network seems to be the thing you are looking for. The LN consists of many payment channels which are connected one to another. The LN transactions are not broadcast to the Bitcoin Network and they are instant in most cases. However, because of the way the LN works, there are problems with payments failures due to routing problems. The coins need to be passed between nodes which are connected via channels which have limited capacity and different liquidity. The Lightning Network involves two on-chain transactions (opening a channel and its closure).

When you open a channel, the coins are moved to a multi-signature address controlled by both nodes. How do we make sure that coins are not stolen by the other party then? Both signatures are required to spend from the address. Each time a channel state is updated, both parties sign a commitment transaction which can be broadcast to the Bitcoin network resulting in the channel closure. A new commitment transaction revokes the previous one which is useful in case the other party attempts to cheat by broadcasting the old channel state. The penalty is included as well. By default, in the case of an uncooperative channel closure, one has 24 hours to publish the penalty transaction. The uncooperative channel closures happen when one of the nodes is offline or if the other node closes the channel forcefully without negotiation. Cooperative channel closures can happen instantly.

As for the LN payments, Hash Time Locked Contracts (https://en.bitcoin.it/wiki/Hash_Time_Locked_Contracts) are used. The following explanation should be fairly easy to understand.

Alice opens a payment channel to Bob, and Bob opens a payment channel to Charlie.
    Alice wants to buy something from Charlie for 1000 satoshis.
    Charlie generates a random number and generates its SHA256 hash. Charlie gives that hash to Alice.
    Alice uses her payment channel to Bob to pay him 1,000 satoshis, but she adds the hash Charlie gave her to the payment along with an extra condition: in order for Bob to claim the payment, he has to provide the data which was used to produce that hash.
    Bob uses his payment channel to Charlie to pay Charlie 1,000 satoshis, and Bob adds a copy of the same condition that Alice put on the payment she gave Bob.
    Charlie has the original data that was used to produce the hash (called a pre-image), so Charlie can use it to finalize his payment and fully receive the payment from Bob. By doing so, Charlie necessarily makes the pre-image available to Bob.
    Bob uses the pre-image to finalize his payment from Alice

You should read my "Basics of The Lightning Network (https://bitcointalk.org/index.php?topic=4940536.msg44524521#msg44524521)" and "The Lightning Network FAQ (https://bitcointalk.org/index.php?topic=5158920.msg51615708#msg51615708)" threads. You will find plenty of information there! There are also a few other second layer protocols which are less popular.


Title: Re: off chain storage for Bitcoin possible?
Post by: jackg on June 19, 2020, 01:03:23 AM
Not sure if bitcryptex mentioned it but the other problem with offchain payments is that your client has to be online to publish the commitment transaction with the penalty within a certain amount of time (normally two weeks by default) but if you can't go online in that time (such as losing Internet in your house, being arrested/kidnaoped for example or your node being hacked) then you risk losing your funds.



Title: Re: off chain storage for Bitcoin possible?
Post by: Rath_ on June 19, 2020, 10:17:46 AM
(normally two weeks by default)

By default, in most cases, it is only 144 blocks (~1 day). For example, Eclair Mobile sets the timelock to 2016 blocks (~2 weeks) for channels which support receiving payments.

but if you can't go online in that time (such as losing Internet in your house, being arrested/kidnaoped for example or your node being hacked) then you risk losing your funds.

Watchtowers are supposed to solve that problem, but they are not impenetrable as well. If a node was hacked, I don't think there would be a need for an uncooperative channel closure :P


Title: Re: off chain storage for Bitcoin possible?
Post by: boissonnea on June 20, 2020, 09:20:20 AM
I wondered if anyone knows more about state channel and off chain storage. We all know that one problem of Bitcoin is scalability.
Off chain storage could be one answer but I don t really understand how that could work.
Has anyone any ideas?

second layer technology (Lightning Network) is not for bitcoin only. it takes transactions away from the main blockchain. so any altcoin so build it’s own second layer.
It is not the solution to all scalability problems, but also the problem of fees for small transactions. The essential advantage lies in its use for frequent purchases from a trusted party such as buying coffee, but this does not mean that all transactions will be made through it.

watch this video for new features https://www.youtube.com/watch?v=W34RdzFwz8M

The Bitcoin Lightning Network Explained https://www.youtube.com/watch?v=Z7Q0AwbKZX8
Misconceptions about Lightning Network https://www.youtube.com/watch?v=c4TjfaLgzj4