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
This commit is contained in:
Michael Schmoock
2020-10-28 11:46:12 +01:00
committed by neil saitug
parent d5d9858b7b
commit 8a8dabaa58
15 changed files with 199 additions and 51 deletions

View File

@@ -64,7 +64,9 @@ void notify_channel_state_changed(struct lightningd *ld,
struct channel_id *cid,
struct short_channel_id *scid,
enum channel_state old_state,
enum channel_state new_state);
enum channel_state new_state,
enum state_change cause,
char *message);
void notify_forward_event(struct lightningd *ld,
const struct htlc_in *in,