What is happening when a channel is pending when opened? How long does it usually take? To open a channel with a node you're already connected to you don't need to get consensus from all the other connected nodes (as you would if you were sending a transaction on chain) so why the wait?
Opening a channel involves sending an on-chain transaction (with a multisig output controlled by the channel’s participants), so when the channel is ‘pending’ it simply means this transaction is not yet confirmed. How long it takes the transaction to confirm depends on the same factors as any other transaction.
Further, the participants will often wait for a certain number of transaction confirmations before starting to make channel payments. The number of confirmations required is negotiated in the
minimum_depth parameter of the
accept_channel message. From BOLT 2:
funding_lockedmessage indicates that the funding transaction has reached the
minimum_depthasked for in
accept_channel. Once both nodes have sent this, the channel enters normal operating mode
(thanks to @jnewbery for the added info)
What is happening when a channel is pending when opened? How long does it usually take?
A node establishes a channel by sending an open_channel message to its desired peer. This message specifies the parameters under which the channel will operate (e.g. the number of bitcoin the channel will be funded with and the cost to route payments through the channel). The channel counterparty must reply with the accept channel message, one parameter of which is
minimum_depth, wherein the number of confirmations the funding transaction must have (before the channel can be used) is specified. This protects channel participants from losing money in the event the funding transaction is double spent.
To open a channel with a node you're already connected to you don't need to get consensus from all the other connected nodes (as you would if you were sending a transaction on chain) so why the wait?
Establishing a network connection with a node is only one step in the process of establishing a lightning channel. The funds must first be secured in a multisignature output (2-of-2, with one key from each channel participant). Moving the funds to a multisignature output can only be done with an on-chain transaction. Without this step there is no way to restrict one party from stealing the funds outright. Once the funds have been moved to such an output, channel participants can make lightning transactions.