Skip to content

Commit 871b22d

Browse files
whitslackrustyrussell
authored andcommitted
lightningd: notify plugins when finalizing channel
Changelog-Added: Plugins now receive `channel_state_changed` notification upon final change to `CLOSED` state.
1 parent 830673f commit 871b22d

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

lightningd/channel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ void delete_channel(struct channel *channel STEALS, bool completely_eliminate)
111111
fatal("HSM gave bad hsm_forget_channel_reply %s", tal_hex(msg, msg));
112112
}
113113

114+
notify_channel_state_changed(channel->peer->ld,
115+
&channel->peer->id,
116+
&channel->cid,
117+
channel->scid,
118+
time_now(),
119+
channel->state,
120+
CLOSED,
121+
channel->state_change_cause,
122+
NULL);
123+
114124
tal_free(channel);
115125

116126
maybe_delete_peer(peer);

wallet/test/run-wallet.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -755,17 +755,6 @@ void notify_channel_mvt(struct lightningd *ld UNNEEDED,
755755
void notify_channel_open_failed(struct lightningd *ld UNNEEDED,
756756
const struct channel_id *cid UNNEEDED)
757757
{ fprintf(stderr, "notify_channel_open_failed called!\n"); abort(); }
758-
/* Generated stub for notify_channel_state_changed */
759-
void notify_channel_state_changed(struct lightningd *ld UNNEEDED,
760-
const struct node_id *peer_id UNNEEDED,
761-
const struct channel_id *cid UNNEEDED,
762-
const struct short_channel_id *scid UNNEEDED,
763-
struct timeabs timestamp UNNEEDED,
764-
enum channel_state old_state UNNEEDED,
765-
enum channel_state new_state UNNEEDED,
766-
enum state_change cause UNNEEDED,
767-
const char *message UNNEEDED)
768-
{ fprintf(stderr, "notify_channel_state_changed called!\n"); abort(); }
769758
/* Generated stub for notify_connect */
770759
void notify_connect(struct lightningd *ld UNNEEDED,
771760
const struct node_id *nodeid UNNEEDED,
@@ -1310,6 +1299,17 @@ u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
13101299
void plugin_hook_db_sync(struct db *db UNNEEDED)
13111300
{
13121301
}
1302+
void notify_channel_state_changed(struct lightningd *ld UNNEEDED,
1303+
const struct node_id *peer_id UNNEEDED,
1304+
const struct channel_id *cid UNNEEDED,
1305+
const struct short_channel_id *scid UNNEEDED,
1306+
struct timeabs timestamp UNNEEDED,
1307+
enum channel_state old_state UNNEEDED,
1308+
enum channel_state new_state UNNEEDED,
1309+
enum state_change cause UNNEEDED,
1310+
const char *message UNNEEDED)
1311+
{
1312+
}
13131313
bool fromwire_hsmd_get_channel_basepoints_reply(const void *p UNNEEDED,
13141314
struct basepoints *basepoints,
13151315
struct pubkey *funding_pubkey)

0 commit comments

Comments
 (0)