3

I have a question regarding lightning network. It's a bit of a long question so please bear with me.

If have 1 bitcoin in my wallet and buy an item costing that amount from a shop. I leave the shop before they have a confirmation (before it's put into a block).

It's my understanding this would put the shop at risk as i still have the 1 bitcoin technically in my wallet as the transaction with the shop is still floating around in the meme pool.

I could at this point create a new transaction sending the 1 bitcoin to another wallet owned by myself. I could attach a relatively large miner fee to this transaction.

This transaction would probably then get put into a block before the shop transaction. If this happened the shop transaction would now be considered invalid as according to the block chain i now have 0 bitcoin in my wallet.

This is why the shop needs to wait for 1 confirmation before allowing me to walk out of the shop with the purchased item.

The problem here is i could potentially be waiting for around 10 minutes before confirmation is received. Bitcoin isn't exactly user friendly from the shops point of view.

I have heard lightning network solves this issue but i don't fully understand why.

My understanding is to open a LN channel with the shop a transaction is created on the main bitcoin block chain.

This transaction would be saying to take 1 btc from my wallet and 0 btc from the shop's wallet and open a multi sig wallet. My understanding being the multi sig wallet is a temporary address which will remain active until the LN channel is closed. When it's closed a new transaction would be created distributing the funds to my wallet and the shop's wallet depending on where the funds were in the LN channel when the channel was closed.

My question is how do confirmations work with regards to the initial transaction which opened the LN channel? When the LN channel is opened presumably this transaction is in the meme pool.

Can i send the 1 btc to the shop in the LN channel while that transaction is still in the meme pool? If yes then surely it's the same situation as before where i could then create another transaction on the main blockchain for 1 btc and if that transaction gets put into a block before the LN transaction is put into a block then the LN transaction would now be invalid.

Basically i don't understand how LN allows instant payment in a shop while maintaining security of that payment from the shops point of view.

I know i must be not fully understanding how this process works. Can anyone shed some light on this?

4

This is a very good question and I will give a quick summary of what is happening here. The longer version can be seen on my educational video on how to create payment channels starting at 33:41 (though I would recommend to watch from the beginning to review bitcoin and notation.)

My understanding being the multi sig wallet is a temporary address which will remain active until the LN channel is closed.

yes this is true! The key is a multi sig address which already prevents the attack setting to the shop which you discribed in the onchain bitcon setting without confirmations. If only you need a key for a double spend you can double spend. In the setting of the multisig you would need collaboration from the victim (shop) which would not do help you

When it's closed a new transaction would be created distributing the funds to my wallet and the shop's wallet depending on where the funds were in the LN channel when the channel was closed

I think this is where you might not have the concept fully right. While it is true that the funds from the multisig wallet will be moved according to the distribution of funds to the two channel partners the initial transaction that spends those funds will be created even before the channel is opened by sending funds to the multisig from which this commitment transactions spends.

All that being said. the funding transaction is not in the mempool as you guessed but in fact confirmed within the blockchain for the channel to be open and operational. So for an initial channel opening (unless using the somewhat special setting which allows turbochannels) one also has to wait for a couple of confirmations to use the channel safely. The setting with the shop also would not require you to have a direct channel with the shop. As soon as both you and the shop have channels connected to the network you should be able to pay the shop over a path of channels without the necessity to open another channel with the shop.

| improve this answer | |
2

The "instant" payment of Lightning is only possible for already-established Lightning channels. New channels are subject to confirmation times like any other bitcoin transaction.

When a channel is opened, the fundee specifies a minimum depth at which the channel must be confirmed for it to be considered active. Once it has been broadcast and has reached minimum depth, the funder will send the fundee a new commitment_point as part of the funding_locked message, and the fundee will respond with an equivalent message. The channel is considered active once both participants have sent the message.

It is not necessary for you to open a new channel with a specific merchant in order to transact with the merchant. The Lightning Network allows you to utilize a network of payment channels to deliver an amount to the merchant through several proxies. These payments are conditional payments, with the condition being that the merchant must surrender a preimage to a hash which was previously agreed with the payer via an invoice.

A payment in LN is not necessarily instant. The time taken depends on how long it takes for the payment request to be forwarded through each of the proxies until it reaches the intended recipient (usually milliseconds). The recipient can potentially withhold the preimage for a period of time, but eventually the payment will expire if they do not explicitly reject the payment or reveal the preimage. (The default expiry setting is 9 blocks I think). It is in the interest of a merchant to reveal it as soon as possible, because the preimage serves the equivalent function of a reciept of payment, and they probably don't want you in their shop for 90 minutes waiting for one.

| improve this answer | |
1

The two answers provided are great, but I just wanted to add something short and to the point, to address what I think is the main point of your misunderstanding:

To open a LN channel, you will coordinate with a peer to create a multi-sig address and funding transaction that pays to it (there are some further details that are agreed upon during channel setup, but we can ignore them for simplicity).

This transaction is then published to the network, and once it is confirmed (with some specified minimum depth), the channel becomes active. You can think of the multisig address UTXO created by this transaction as representing the channel (more or less.. there is additional information about the channel state, known to the LN nodes, but for simplicity we can again ignore that for now).

To close the channel, the channel's peers will craft and publish a second transaction, which consumes the multisig UTXO and pays funds to each channel participant as appropriate and agreed upon. Once this transaction confirms, the channel will be closed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.