2018-02-19 02:06:14 +01:00
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_CHANNEL_STATE_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_CHANNEL_STATE_H
|
2017-05-22 13:24:59 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2020-10-28 11:46:23 +01:00
|
|
|
#include <ccan/time/time.h>
|
|
|
|
|
2018-02-19 02:06:14 +01:00
|
|
|
/* These are in the database, so don't renumber them! */
|
|
|
|
enum channel_state {
|
2017-05-22 13:27:20 +02:00
|
|
|
/* In channeld, still waiting for lockin. */
|
2018-02-19 02:06:14 +01:00
|
|
|
CHANNELD_AWAITING_LOCKIN = 2,
|
2017-05-22 13:24:59 +02:00
|
|
|
|
|
|
|
/* Normal operating state. */
|
2017-05-22 13:27:20 +02:00
|
|
|
CHANNELD_NORMAL,
|
2017-05-22 13:24:59 +02:00
|
|
|
|
|
|
|
/* We are closing, pending HTLC resolution. */
|
2017-06-26 03:16:43 +02:00
|
|
|
CHANNELD_SHUTTING_DOWN,
|
2017-05-22 13:24:59 +02:00
|
|
|
|
|
|
|
/* Exchanging signatures on closing tx. */
|
2017-05-22 13:27:20 +02:00
|
|
|
CLOSINGD_SIGEXCHANGE,
|
2017-05-22 13:24:59 +02:00
|
|
|
|
2017-07-05 07:33:40 +02:00
|
|
|
/* Waiting for onchain event. */
|
|
|
|
CLOSINGD_COMPLETE,
|
|
|
|
|
2018-08-23 03:08:48 +02:00
|
|
|
/* Waiting for unilateral close to hit blockchain. */
|
|
|
|
AWAITING_UNILATERAL,
|
|
|
|
|
2017-09-26 23:02:48 +02:00
|
|
|
/* We've seen the funding spent, we're waiting for onchaind. */
|
|
|
|
FUNDING_SPEND_SEEN,
|
|
|
|
|
2018-02-23 07:23:51 +01:00
|
|
|
/* On chain */
|
2019-06-22 14:49:30 +02:00
|
|
|
ONCHAIN,
|
|
|
|
|
|
|
|
/* Final state after we have fully settled on-chain */
|
2020-11-24 02:43:02 +01:00
|
|
|
CLOSED,
|
|
|
|
|
|
|
|
/* For dual-funded channels, we start at a different state.
|
|
|
|
* We transition to 'awaiting lockin' after sigs have
|
|
|
|
* been exchanged */
|
|
|
|
DUALOPEND_OPEN_INIT,
|
|
|
|
|
|
|
|
/* Dual-funded channel, waiting for lock-in */
|
|
|
|
DUALOPEND_AWAITING_LOCKIN,
|
2017-05-22 13:24:59 +02:00
|
|
|
};
|
2020-11-24 02:43:02 +01:00
|
|
|
#define CHANNEL_STATE_MAX DUALOPEND_AWAITING_LOCKIN
|
2017-05-22 13:24:59 +02:00
|
|
|
|
feat: adds state change cause and message
This adds a `state_change` 'cause' to a channel.
A 'cause' is some initial 'reason' a channel was created or closed by:
/* Anything other than the reasons below. Should not happen. */
REASON_UNKNOWN,
/* Unconscious internal reasons, e.g. dev fail of a channel. */
REASON_LOCAL,
/* The operator or a plugin opened or closed a channel by intention. */
REASON_USER,
/* The remote closed or funded a channel with us by intention. */
REASON_REMOTE,
/* E.g. We need to close a channel because of bad signatures and such. */
REASON_PROTOCOL,
/* A channel was closed onchain, while we were offline. */
/* Note: This is very likely a conscious remote decision. */
REASON_ONCHAIN
If a 'cause' is known and a subsequent state change is made with
`REASON_UNKNOWN` the preceding cause will be used as reason, since a lot
(all `REASON_UNKNOWN`) state changes are a subsequent consequences of a prior
cause: local, user, remote, protocol or onchain.
Changelog-Added: Plugins: Channel closure resaon/cause to channel_state_changed notification
2020-10-28 11:46:12 +01:00
|
|
|
enum state_change {
|
|
|
|
/* Anything other than the reasons below. Should not happen. */
|
|
|
|
REASON_UNKNOWN,
|
|
|
|
|
|
|
|
/* Unconscious internal reasons, e.g. dev fail of a channel. */
|
|
|
|
REASON_LOCAL,
|
|
|
|
|
|
|
|
/* The operator or a plugin opened or closed a channel by intention. */
|
|
|
|
REASON_USER,
|
|
|
|
|
|
|
|
/* The remote closed or funded a channel with us by intention. */
|
|
|
|
REASON_REMOTE,
|
|
|
|
|
|
|
|
/* E.g. We need to close a channel because of bad signatures and such. */
|
|
|
|
REASON_PROTOCOL,
|
|
|
|
|
|
|
|
/* A channel was closed onchain, while we were offline. */
|
|
|
|
/* Note: This is very likely a conscious remote decision. */
|
|
|
|
REASON_ONCHAIN
|
|
|
|
};
|
|
|
|
|
2020-10-28 11:46:23 +01:00
|
|
|
struct state_change_entry {
|
|
|
|
struct timeabs timestamp;
|
|
|
|
enum channel_state old_state;
|
|
|
|
enum channel_state new_state;
|
|
|
|
enum state_change cause;
|
|
|
|
char *message;
|
|
|
|
};
|
|
|
|
|
2018-02-19 02:06:14 +01:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_STATE_H */
|