A state machine.



Summary:

The Lightning Network protocol is a complex system that includes various states and inputs. The states are divided into different sub-states, each with multiple actions that can be taken. These actions include stealing, spending, mutual close, and commit. There is also a state where all previous transactions have been completed.The inputs to the system include packet inputs like open, update, and close, as well as non-packet inputs like Bitcoin events and timeouts. Bitcoin events include anchor depth being okay, not reaching the required depth in time, and other spends of the anchor.The author has created a state machine for the wire protocol that handles all the commands and bitcoin event notifications. The protocol responds to protocol violations with an error packet and unilateral close. The different states of the machine are defined in the code and enumerated in state_types.h. These states cover everything from initialization without an anchor to normal update loop to closing, which is again divided into categories like waiting for close complete and waiting for close ack.In addition to these states, the protocol allows for broadcasting one or more revoked commit tx or their latest commit tx at any time. They respond to revoked commit txs by stealing their funds (steal) and respond to their latest commit tx by spending (spend_them). They can also broadcast a mutual close tx (mutual_close) with our help.The Lightning Network protocol is an extensive system that covers a wide range of situations and inputs with various commands to handle them. Although the author has pasted state_types.h in his state branch and will do a proper RFC eventually, including all the transactions.


Updated on: 2023-05-23T19:43:35.728502+00:00