You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.2 KiB
100 lines
2.2 KiB
9 years ago
|
#ifndef LIGHTNING_STATE_TYPES_H
|
||
|
#define LIGHTNING_STATE_TYPES_H
|
||
9 years ago
|
#include "config.h"
|
||
9 years ago
|
/* FIXME: cdump is really dumb, so we put these in their own header. */
|
||
|
#include "lightning.pb-c.h"
|
||
|
|
||
|
enum state {
|
||
9 years ago
|
STATE_INIT,
|
||
9 years ago
|
|
||
|
/*
|
||
|
* Opening.
|
||
|
*/
|
||
8 years ago
|
STATE_OPEN_WAIT_FOR_OPENPKT,
|
||
8 years ago
|
STATE_OPEN_WAIT_FOR_ANCHORPKT,
|
||
|
STATE_OPEN_WAIT_FOR_COMMIT_SIGPKT,
|
||
|
|
||
|
/* We're waiting for depth+their complete. */
|
||
|
STATE_OPEN_WAIT_ANCHORDEPTH_AND_THEIRCOMPLETE,
|
||
|
/* Got their pkt_complete. */
|
||
|
STATE_OPEN_WAIT_ANCHORDEPTH,
|
||
|
/* Got anchor depth. */
|
||
|
STATE_OPEN_WAIT_THEIRCOMPLETE,
|
||
9 years ago
|
|
||
|
/*
|
||
9 years ago
|
* Normal state.
|
||
9 years ago
|
*/
|
||
9 years ago
|
STATE_NORMAL,
|
||
|
STATE_NORMAL_COMMITTING,
|
||
9 years ago
|
|
||
9 years ago
|
/*
|
||
9 years ago
|
* Closing (handled outside state machine).
|
||
9 years ago
|
*/
|
||
8 years ago
|
STATE_SHUTDOWN,
|
||
|
STATE_SHUTDOWN_COMMITTING,
|
||
9 years ago
|
STATE_MUTUAL_CLOSING,
|
||
9 years ago
|
|
||
9 years ago
|
/* Four states to represent closing onchain (for getpeers) */
|
||
|
STATE_CLOSE_ONCHAIN_CHEATED,
|
||
|
STATE_CLOSE_ONCHAIN_THEIR_UNILATERAL,
|
||
|
STATE_CLOSE_ONCHAIN_OUR_UNILATERAL,
|
||
|
STATE_CLOSE_ONCHAIN_MUTUAL,
|
||
|
|
||
9 years ago
|
/* All closed. */
|
||
|
STATE_CLOSED,
|
||
|
|
||
9 years ago
|
/*
|
||
|
* Where angels fear to tread.
|
||
|
*/
|
||
9 years ago
|
/* Bad packet from them / protocol breakdown. */
|
||
|
STATE_ERR_BREAKDOWN,
|
||
8 years ago
|
/* The anchor didn't reach blockchain in reasonable time. */
|
||
9 years ago
|
STATE_ERR_ANCHOR_TIMEOUT,
|
||
9 years ago
|
/* We saw a tx we didn't sign. */
|
||
|
STATE_ERR_INFORMATION_LEAK,
|
||
9 years ago
|
/* We ended up in an unexpected state. */
|
||
|
STATE_ERR_INTERNAL,
|
||
|
|
||
|
STATE_MAX
|
||
|
};
|
||
|
|
||
|
enum state_input {
|
||
9 years ago
|
/*
|
||
|
* Packet inputs.
|
||
|
*/
|
||
9 years ago
|
PKT_OPEN = PKT__PKT_OPEN,
|
||
|
PKT_OPEN_ANCHOR = PKT__PKT_OPEN_ANCHOR,
|
||
|
PKT_OPEN_COMMIT_SIG = PKT__PKT_OPEN_COMMIT_SIG,
|
||
|
PKT_OPEN_COMPLETE = PKT__PKT_OPEN_COMPLETE,
|
||
9 years ago
|
|
||
|
/* Updating the commit transaction: new HTLC */
|
||
9 years ago
|
PKT_UPDATE_ADD_HTLC = PKT__PKT_UPDATE_ADD_HTLC,
|
||
9 years ago
|
/* Updating the commit transaction: I have your R value! */
|
||
|
PKT_UPDATE_FULFILL_HTLC = PKT__PKT_UPDATE_FULFILL_HTLC,
|
||
|
/* Updating the commit transaction: your HTLC failed upstream */
|
||
9 years ago
|
PKT_UPDATE_FAIL_HTLC = PKT__PKT_UPDATE_FAIL_HTLC,
|
||
9 years ago
|
|
||
9 years ago
|
/* Committing updates */
|
||
|
PKT_UPDATE_COMMIT = PKT__PKT_UPDATE_COMMIT,
|
||
|
PKT_UPDATE_REVOCATION = PKT__PKT_UPDATE_REVOCATION,
|
||
9 years ago
|
|
||
9 years ago
|
/* If they want to close. */
|
||
8 years ago
|
PKT_CLOSE_SHUTDOWN = PKT__PKT_CLOSE_SHUTDOWN,
|
||
9 years ago
|
|
||
|
/* Something unexpected went wrong. */
|
||
9 years ago
|
PKT_ERROR = PKT__PKT_ERROR,
|
||
|
|
||
9 years ago
|
/*
|
||
|
* Non-packet inputs.
|
||
|
*/
|
||
9 years ago
|
INPUT_NONE,
|
||
|
|
||
|
/*
|
||
|
* Timeouts.
|
||
|
*/
|
||
|
INPUT_CLOSE_COMPLETE_TIMEOUT,
|
||
9 years ago
|
|
||
9 years ago
|
INPUT_MAX
|
||
|
};
|
||
|
#endif /* LIGHTNING_STATE_TYPES_H */
|