Channels - Firescar96/lit GitHub Wiki

The channels page contains all the peer functionality of Lit including Lightning Network channels and chat. The page is broken into 4 main sections and multiple modals. Different portions of the page require the ability to view and modify the current set of peers and channels so that state is managed via a single store simply called 'Store'. Other section or modal specific state is contained within the appropriate React element.

The window session storage is used to maintain the currently selected peer and channel across page refreshes. It's updated when a user makes a selection and used by the Store to get the initial peer and channel selection.

Listening Section

This section displays the user's public key, which is needed to connect to peers on the Lightning Network. There is also a toggle to allow the user to enable listening so other peers can connect to them.

Peers Section

This section displays an interactive list of peers. When a user clicks on a peer from the list any relevant channels show up in the Channels Section and the latest chat messages show up in the Chat Section.

  • Clicking the plus button opens a modal for adding a peer via their pubkey, ip address, and port.
  • Users can give a peer a nickname or change a peer's nickname by clicking the appropriate button; thus openning the nickname modal

Channels Section

Every channel the user is currently engaged in with a given peer is shown here. In practice users should not ever be in more than 2 or 3 channels with one peer at a time. This sets an upper bound on the size of the channels list so even though it shares vertical space with the chats, the Chat Section should never become too small.

  • Clicking the plus button opens a modal for opening a new channel with a peer.
  • Clicking the Zap button transfers the specified amount of satoshis over the channel and instantly updates the current balance.
  • Clicking the Xtra options button opens a modal with the option to either close or break the channel
    • Breaking a channel locks up user money for a long time so if they select to break the channel an additional confirmation dialog is used to ensure the user didn't accidentally click the button.

Chat Section

Both sent and received chats appear here in real time. Received chats appear on the left in blue and sent chats appear on the right in yellow.