-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add channel closure details #4126
feat: add channel closure details #4126
Conversation
73aa2c8
to
6457b02
Compare
ae455c1
to
6ecc5eb
Compare
6ecc5eb
to
c97ab5a
Compare
@cdecker @rustyrussell |
c97ab5a
to
a427178
Compare
added missing documentation. |
9be595c
to
6db7961
Compare
6db7961
to
ac0b8d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice PR. Just some bike-shedding on who is to blame for various state changes and some cleanup suggestions.
9442d1d
to
439e0ba
Compare
@cdecker do you think we should remove |
Sorry for burying the reply to this in a thread:
|
@cdecker I will also extend on the testcases to also cover some of the itnernal/protocol reasons. |
439e0ba
to
3dbf04f
Compare
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
Changelog-Added: RPC: Added 'opener' and 'closer' to listpeers channels
Changelog-Added: RCP: Added 'state_changes' history to listpeers channels
3dbf04f
to
edca8cb
Compare
ACK edca8cb |
Ready for review
This adds a
state_change
cause to a channel in order to tell if it was closed (or opened) for"REMOTE"
,"LOCAL"
,"USER"
,"PROTOCOL"
or"ONCHAIN"
reasons. Since a lot of state changes are subsequent results of a prior cause, we store the last known ( not REASON_UNKNOWN )state_change
as cause for subsequent state changes. We add a database table that stores all state changes with their distinct cause and message.state_change cause
andenum side closer
tostruct channel
char * message
state_change
cause and message in DBlistpeers
channelsstate_change
history with cause, message and timestamp in DBstate_change
history tolistpeers
or a new command?Addresses #4027
Questions:
htlc.h
enum side
ascloser
and initializing it in DB withNUM_SIDES := 2
(kinda whacky t.b.h.) we can introduce anenum closer
which can be e.g.CLOSER_NONE
,CLOSER_LOCAL
,CLOSER_REMOTE
and maybeCLOSER_ONCHAIN
. Or, if we already wantCLOSER_ONCHAIN
we can use theenum state_change
for this which covers all of the above + 'CLOSER_USER
', but then that's another recycling. Please advice.