Transactions and channels on the lightning network

A person goes to a coffee shop and pays through lightning:

1- Since its the first transaction between these 2 wallets, does a new channel has to be open ? Or it goes through another channel that eventually connects these 2 wallets ? Whats if it the first time the customer uses lightning ?

2- When, why and how a channel is closed ? If the customer goes to the coffee shop every day, whats the incentive to close the channel ? And whats the incentive on the coffee shop side ?

3- Who pays for the expenses to open a channel ?

anyone to help me with this ?

Hi. Master.
I can try to help you with this. :slightly_smiling_face:

  1. A Lightning channel is the routing between nodes, so if a customer is buying a coffee from let’s say Starbucks, the customer will have to establish a connection to a lightning node that is able to route the payment through to Starbucks. But I think Starbucks will offer a solution for the customer to connect directly to their node.

  2. I don’t see the reason to close a channel unless the funds are all spent. I may be wrong about this.

  3. The cost would be just the initial cost to make a TX on the blockchain. That depends on the TX fee at the time of the transaction. Let`s say we agree to open a channel between us two, the TX fee will depend on the number of unconfirmed transactions on the Bitcoin network at that time. the tx fee will be deducted from the transaction as normal.

I hope this was to some help for you.
What is the project you are working on? I`m starting to set up a node and test communication trough gPRC and REST. :face_with_monocle:

Good luck.
Ivo

Thanks a lot, Ivo… i shall continue with more questions ahah

  1. So when i download a lightning wallet and put funds to get a coffee, is this wallet a node ? if its not, how would open a channel with starbucks ?

  2. a channel would be open with the first transaction and shall stay there forever ? Assuming the costumer is someone with 0 knowledge and just downloaded a lightning wallet to buy coffee in another country so there is no need to convert currency or whatever

  3. If the customer if the active part/sender on the transaction, wouldnt he pay for the tx fees on chain ?

Bonus Question. based on a lot of assumptions: if the costumers wallet is not a full node, how would the channel be created ? could it use the underlaying full node of the “light” lightning wallet ? If so, could use the same channel a previous costumer of the same wallet opened ?

Your lightning wallet on your phone is a “lightnode” that is connected with the main node you are connected to. The node you are connected to are most likely a national node of some sort, that someone has already started and that have some connections already. A customer with 0 knowledge will not have its own node, but most likely be connected to some node he/she trusts. Starbucks will most likely have its own node and with established connections to maybe the main node that the customer is connected to.

It’s hard for me to predict exactly what solution Starbucks will implement in the future.
But the concept is the same.
If you think of it as VISA, then you understand that your card is not connected to Starbucks directly, but since Starbucks is a customer of VISA they get the money when the customer pays for the coffee. The money are then routed through VISA’s system and Starbucks has to pay the VISA transaction fee for every time you swipe your card.

In lightning, Starbucks will have to establish a connection with whatever Node (btcPay) that has the most of the potential clients that Starbucks wants to sell coffee to. And the only time the customer will pay a fee is when they establish a connection to a node (btcPay) and when they close the channel when the funds they funded the channel with is spent. A lightning transaction has 0 fees because it is a second-layer solution, it’s the BTC TX that generates a fee.

I think Filip explains how the lightning network works in the course. There is nothing wrong with taking a repetition of how it works. :face_with_monocle:

Here are some useful links you can look at.

You can read the whitepaper here:

Here you can read what solutions BtcPay offers at this time.

You should take a look at this video, it will talk about opening a payment channel and closing a payment channel. Starts at 4:00 min

I hope this was helpful to you. Let me know if you need more help. :wink:

Ivo

1 Like

Since one week I’m running a RaspiBlitz Bitcoin full node. I also open a few channels with 1.000.000 satoshi. After a few transactions via my node (not my own transactions) my local balance decreased to zero and the remote balance is now 1.000.000.
Can I still doing payment or can I only receive payment with this channel?

If you only emptied one channel you can rebalance your channels so they will have approximately the same balance. If you emptied all of them, then you will have to fund one of the channels to be able to send funds again. :slight_smile: