ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.83k stars 898 forks source link

Add new notifications for plugins #3662

Open darosior opened 4 years ago

darosior commented 4 years ago

A feedback from a plugin developer on IRC.

Could I have the feature request flag please ?.. :-) EDIT: Thanks !

cdecker commented 4 years ago

Added a couple of tags as requested :-)

I think this might be a good first issue for new contributors since it can be implemented using existing infrastructure.

I wanted to say that the hook can be used like a notification by returning {"result": "continue"}, however notifications can be dispatched in parallel, while hooks are called sequentially, so there's definitely a good reason to add the hook as well.

fiatjaf commented 4 years ago

Having the reason for the channel closure somehow would be great (mutual from us, mutual from them, unilateral because of fees, unilateral because of expiring HTLCs, or other reasons).

m-schmoock commented 3 years ago

Hm is channel_closed notification covered by channel_state_changed notification with i.e. old_state == CHANNELD_NORMAL ?

m-schmoock commented 3 years ago

Also htlc_accepted is already a hook that is chainable (iirc) and thus can be used as a notification

shinghim commented 3 years ago

Hm is channel_closed notification covered by channel_state_changed notification with i.e. old_state == CHANNELD_NORMAL ?

if we use channel_state_changed to notify closed channels, would we just need to add the reasons for the closure (MUTUAL_USER, MUTUAL_PEER, UNILATERAL_EXPIRING_HTLC, etc)?

m-schmoock commented 3 years ago

According to doc/PLUGINS.md it says a channel_state_changed event looks like this and includes a cause which indicates from which side the channel was closed:

{
    "channel_state_changed": {
        "peer_id": "03bc9337c7a28bb784d67742ebedd30a93bacdf7e4ca16436ef3798000242b2251",
        "channel_id": "a2d0851832f0e30a0cf778a826d72f077ca86b69f72677e0267f23f63a0599b4",
        "short_channel_id" : "561820x1020x1",
        "old_state": "CHANNELD_NORMAL",
        "new_state": "CHANNELD_SHUTTING_DOWN",
        "cause" : "remote",
        "message" : "Peer closes channel"
    }
}

A cause can have the following values: