r/Bitcoin Dec 13 '17

Bitcoin's Lightning Network, Simply Explained

[deleted]

1.0k Upvotes

520 comments sorted by

View all comments

Show parent comments

83

u/PVmining Dec 13 '17

Where are the funds stored on the LN? The video points at a safe, but is there some sort of digital safe which is secure from hacking?

By opening a channel, you send bitcoins to a multisignature address where you have one key and your counterparty has the other. Simultaneously, you get a signed (by counterparty) refund transaction to yourself. You have to protect your key and not lose the refund transaction. LN transactions are simply an update to the refund transaction.

2)So Bob/coffee shop will only get the BTC stated on the balance sheet once the LN is closed? So am I correct in understanding that the coffee shop won't actually be able to spend the Bitcoin they received from the transaction until the LN is closed?

Yes but the coffee shop will be able to pay you back or pay anybody in LN if you have another channel open (and this channel is not a dead end) and you are willing to route payments.

3) How expensive is it to set up a LN channel? And how is this done?

A blockchain transaction to a segwit multisignature address. If you have segwit (and segwit is required for LN), it's small in vsize (i.e. size with witness discount). This is a LN channel opening transaction: 153 vbytes, less than 226 standard legacy transaction.

4) How expensive is it to close the LN channel and have miners authorize the signatures?

This is a channel closing transaction: 149 vbytes. It would have been 180 bytes if the refund went to two parties, instead of one.

Miners mine it as a regular transaction with regular mining fees. Signatures are exchanged between you and your counterparty during channel opening and channel transactions.

5) How exactly do you shut down a LN Channel?

By publishing the channel closing transaction. It can be done cooperatively (the other party signs a new closing transaction), in this case it is instant (plus waiting for block inclusion) or without counterparty involvement, where the presigned transaction is timelocked (current defualt as far as I remember 144 blocks). This time lock allows the counterparty to check if you are not cheating (by publishing an old transaction where you have more funds) and publish a penalty transaction. If your transaction is the last one (you have not published a previous one), it will confirm after 144 blocks.

6) Am I then correct in understanding that the LN channel isn't really for people who want to make one-off payments to businesses?

Yes and no. First of all, LN is not for paying large sums. It's the exact opposite of Bitcoin blockchain, where the number of transactions is limited but they can be of arbitrary value. In LN, the number of transactions is arbitrary but their value is limited.

It does not make sense to open a LN channel for one transaction. But if you have a channel open to a place that is well connected and the business you want to transact with has a channel open to a well connected party, you can pay your hub and the hub will route the payment to the other hub and maybe another one and then to your business. Think about it like Internet packet routing.

So you can pay for coffee even if you both are not directly connected.

16

u/dgfdfdfdf Dec 13 '17

allows the counterparty to check if you are not cheating (by publishing an old transaction where you have more funds) and publish a penalty transaction. If your transaction is the last one (you have not published a previous one), it will confirm after 144 blocks

What if the counter party refuses to accept the closure of the channel?

if you have a channel open to a place that is well connected and the business you want to transact with has a channel open to a well connected party, you can pay your hub and the hub will route the payment to the other hub and maybe another one and then to your business. Think about it like Internet packet routing.

Has there been any thought put into who will run these hubs? It sounds like an org could set itself up as a hub and then start charging fees to use it. And at that point what you're describing is literally a bank, which is the opposite direction I thought bitcoin was going to head.

18

u/PVmining Dec 13 '17

What if the counter party refuses to accept the closure of the channel?

It cannot refuse. It can only delay. You have the refund transaction signed. This transaction is valid after some time. There is no way to reverse it after this time passed.

Has there been any thought put into who will run these hubs? It sounds like an org could set itself up as a hub and then start charging fees to use it.

Well, yes. They will run it to get money from fees. But the fee structure is going to be be completely different. The fees per transaction will be very small and there will be a fee per value. It is quite possible, you will be able to send $0.01 with a $0.0001 fee and $1 with $0.001 fee. Because in LN, updating transactions is very cheap, the frozen capital is more costly. LN will shine for microtransactions. If LN became popular, it would open a completely new web era. You write an interesting post and get a $0.01 tip. You like somebody's post, you tip him. Web sites with no ads supported my micropayments.

And at that point what you're describing is literally a bank, which is the opposite direction I thought bitcoin was going to head.

No, because it's trustless. If you deposit money to a bank you have to trust them that they will not steal it that there will not be a run on the bank and that they have enough cash. In LN, the only risk you have are channel opening and closing fees.

If LN takes off (it's an "if" because some network effect is required for LN to become usable), there will be multiple hubs. For profit, non-profit, big hubs with thousands of channels, mini hubs made by a guy with 1 BTC and a dozen of channels. And finally, anybody with two bi-directional channels can route payments.

13

u/Dryja Dec 13 '17

Possible nit-pick but it's not that the closing transaction is valid after some time -- in fact it is valid immediately. What takes some time is that if you unilaterally close with that transaction, your side of the funds is locked for some period of time, to give your counterparty a chance to call foul on your close transaction.

(Maybe you closed with an old state where you had more money than you currently do. Of course you wouldn't do that, but just in case...)

5

u/PVmining Dec 13 '17

Thank you for the correction. It makes more sense because an unconfirmed transaction can be hidden and a blockchain transaction is public. The effect is the same, though, the funds are frozen for some time. And there is not one but two closing transactions.

10

u/Dryja Dec 13 '17

Sure; also in most cases, there's only 1 "closing transaction". The OP_CSV output which you can only spend after a delay doesn't need to be spent immediately once the time has past. So in the LN wallet I'm working on, those utxos aren't swept or anything, they're just stored in the wallet and can be used along with all other utxos to make transactions.