What is the difference between connecting to a node and opening a channel with a node in the lightning network? What are the events happen when I just connect to a node?
2 Answers
When you connect to a node in the lightning network, you are opening a network connection to that node. You begin exchanging messages about the lightning network and can gather information such as other open channels, other nodes that can be connected to, etc. This information can help you build a better channel graph and decide whether you want to open a channel with this node or with some other node.
Once you have connected to a node, you can open a channel with it. Opening a channel requires creating a Bitcoin transaction, broadcasting it to the Bitcoin network, and waiting for it to become confirmed. When you open a channel, you must also be connected to the other node as you need to send information about the channel, such as channel updates, to that node.
In Simple Terms:
Before opening a channel, you want to make sure that you can securely communicate with each other.
- With the
lnd
implementation you do this with:lncli connect <PUBKEY>@<HOST>:<PORT>
- With the
This only tries to establish a stable connection with your peer
.
Then you can open a
channel
with yourpeer
. You can specify a local amount you want to commit to the channel.- With the
lnd
implementation you do this with:lncli openchannel --node_key=<ID_PUBKEY> --local_amt=<AMOUNT>
- With the
After opening a channel, you will have to wait for a number of confirmations. The reason for this is that by opening a channel you make a transaction on the bitcoin network.
- With the
lnd
implementation you can set the number of blocks with the flag:--block
- With the
Hope this answers your question.