A state machine.



Summary:

The Lightning Network protocol is a transaction protocol for Bitcoin that operates through various states. The protocol was created by Rusty Russell and includes several different types of states that are used to handle different types of transactions. The first section of the protocol outlines the normal opening states, which include INIT_NOANCHOR and OPEN_WAIT_FOR_COMMIT_SIG. These opening states are followed by an operational state loop that has two parts: NORMAL_LOWPRIO and NORMAL_HIGHPRIO. This loop alternates between the two parts and includes several commands such as PKT_UPDATE and CMD_SEND_CLOSE.In addition to the normal closing process, there are also weirder closing states that are used when transactions have been stolen or closed unilaterally. For example, in the CLOSE_WAIT_STEAL state, the BITCOIN_ANCHOR_THEIRSPEND signal triggers the transaction to enter the CLOSE_WAIT_STEAL_SPENDTHEM state. Conversely, in the CLOSE_WAIT_SPENDTHEM state, the transaction enters the CLOSE_WAIT_STEAL_SPENDTHEM state when a BITCOIN_ANCHOR_OTHERSPEND signal is received. There are several other sub-states, such as CLOSE_WAIT_SPENDOURS and CLOSE_WAIT_STEAL_SPENDOURS, for handling different types of signals. Finally, the protocol includes several wait states, such as WAIT_FOR_HTLC_ACCEPT_LOWPRIO and WAIT_FOR_UPDATE_COMPLETE_HIGHPRIO, each with its own set of commands and responses. Specific signals like BITCOIN_CLOSE_DONE and INPUT_CLOSE_COMPLETE_TIMEOUT are also handled through specific states.


Updated on: 2023-05-23T19:50:28.960532+00:00