Skip to content

Commit

Permalink
doc: update channel_state_changed notification
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmoock committed Nov 5, 2020
1 parent d900395 commit 3dbf04f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
30 changes: 27 additions & 3 deletions doc/PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ into a block.
### `channel_state_changed`

A notification for topic `channel_state_changed` is sent every time a channel
changes its state. The notification includes the peer and channel ids as well
as the old and the new channel states.
changes its state. The notification includes the `peer_id` and `channel_id`, the
old and new channel states, the type of `cause` and a `message`.

```json
{
Expand All @@ -335,11 +335,35 @@ as the old and the new channel states.
"channel_id": "a2d0851832f0e30a0cf778a826d72f077ca86b69f72677e0267f23f63a0599b4",
"short_channel_id" : "561820x1020x1",
"old_state": "CHANNELD_NORMAL",
"new_state": "CHANNELD_SHUTTING_DOWN"
"new_state": "CHANNELD_SHUTTING_DOWN",
"cause" : "remote",
"message" : "Peer closes channel"
}
}
```

A `cause` can have the following values:
- "unknown" Anything other than the reasons below. Should not happen.
- "local" Unconscious internal reasons, e.g. dev fail of a channel.
- "user" The operator or a plugin opened or closed a channel by intention.
- "remote" The remote closed or funded a channel with us by intention.
- "protocol" We need to close a channel because of bad signatures and such.
- "onchain" A channel was closed onchain, while we were offline.

Most state changes are caused subsequentially for a prior state change, e.g.
"CLOSINGD_COMPLETE" is followed by "FUNDING_SPEND_SEEN". Because of this, the
`cause` reflects the last known reason in terms of local or remote user
interaction, protocol reasons, etc. More specifically, a `new_state`
"FUNDING_SPEND_SEEN" will likely _not_ have "onchain" as a `cause` but some
value such as "REMOTE" or "LOCAL" depending on who initiated the closing of a
channel.

Note: If the channel is not closed or being closed yet, the `cause` will reflect
which side "remote" or "local" opened the channel.

Note: If the cause is "onchain" this was very likely a conscious decision of the
remote peer, but we have been offline.

### `connect`

A notification for topic `connect` is sent every time a new connection
Expand Down
12 changes: 10 additions & 2 deletions doc/lightning-listpeers.7

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion doc/lightning-listpeers.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ The objects in the *channels* array will have at least these fields:
peer, or a theft attempt).
* `"CLOSED"`: The channel closure has been confirmed deeply.
The channel will eventually be removed from this array.
* *state_changes*: An array of objects describing prior state change events.
* *opener*: A string `"local"` or `"remote`" describing which side opened this
channel.
* *closer*: A string `"local"` or `"remote`" describing which side
closed this channel or `null` if the channel is not (being) closed yet.
* *status*: An array of strings containing the most important log messages
relevant to this channel.
Also known as the "billboard".
Expand Down Expand Up @@ -211,7 +216,7 @@ Objects in the *htlcs* array will contain these fields:
* *payment\_hash*: The payment hash, whose preimage must be revealed to
successfully claim this HTLC.
* *state*: A string describing whether the HTLC has been communicated to
or from the peer, whether it has been signed in a new commitment, whether
or from the peer, whether it has been signed in a new commitment, whether
the previous commitment (that does not contain it) has been revoked, as
well as when the HTLC is fulfilled or failed offchain.
* *local\_trimmed*: A boolean, existing and `true` if the HTLC is not
Expand Down

0 comments on commit 3dbf04f

Please sign in to comment.