# Managing Channels

Channels are the basic building blocks of the Lightning Network. With channels, you can transact not only with your immediate peers but with others on the network. Let's explore how to open and close channels with LDK.

# Opening a Channel

Now that you have a peer, you can open a channel with them using ChannelManager. You'll need the peer's pubkey as before along with:

  • the amount in sats to use when funding the channel,
  • any msats to push to your peer,
  • an id which is given back in the FundingGenerationReady event, and
  • an optional UserConfig for overriding ChannelManager defaults

Channels can be announced to the network or can remain private, which is controlled via UserConfig::announced_channel.

    At this point, an outbound channel has been initiated with your peer and it will appear in ChannelManager::list_channels. However, the channel is not yet funded. Once your peer accepts the channel, you will be notified with a FundingGenerationReady event. It's then your responsibility to construct the funding transaction and pass it to ChannelManager, which will broadcast it once it receives your channel counterparty's signature.

      After ChannelManager has broadcast the funding transaction, the channel will become usable once the transaction has enough confirmations and will appear in ChannelManager::list_usable_channels. See the guide on Blockchain Data for details on confirmations.

      With a fully funded channel, you can now make Lightning payments! No more hefty on-chain fees and long confirmation times when you're transacting on layer 2.

      # Closing a Channel

      While a channel can remain open indefinitely, there may come a time when you need to close it. There are two ways to close a channel: either cooperatively or unilaterally. The cooperative case makes for lower fees and immediate access to funds while the unilateral case does not. The latter may be necessary if your peer isn't behaving properly or has gone offline.

        Now that we know how to manage channels, let's put our new channel to use!

        Last Updated: 11/4/2021, 10:12:09 AM