diff --git a/lightningd/notification.c b/lightningd/notification.c index b006fb3ef..4cfac31ea 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -5,7 +5,6 @@ #include const char *notification_topics[] = { - "connect", "disconnect", "warning", "invoice_payment", @@ -39,13 +38,27 @@ bool notifications_have_topic(const char *topic) return false; } +static void connect_notification_serialize(struct json_stream *stream, + struct node_id *nodeid, + struct wireaddr_internal *addr) +{ + json_add_node_id(stream, "id", nodeid); + json_add_address_internal(stream, "address", addr); +} + +REGISTER_NOTIFICATION(connect, + connect_notification_serialize); + void notify_connect(struct lightningd *ld, struct node_id *nodeid, struct wireaddr_internal *addr) { - struct jsonrpc_notification *n = - jsonrpc_notification_start(NULL, "connect"); - json_add_node_id(n->stream, "id", nodeid); - json_add_address_internal(n->stream, "address", addr); + void (*serialize)(struct json_stream *, + struct node_id *, + struct wireaddr_internal *) = connect_notification_gen.serialize; + + struct jsonrpc_notification *n + = jsonrpc_notification_start(NULL, connect_notification_gen.topic); + serialize(n->stream, nodeid, addr); jsonrpc_notification_end(n); plugins_notify(ld->plugins, take(n)); } @@ -149,7 +162,3 @@ void notify_forward_event(struct lightningd *ld, jsonrpc_notification_end(n); plugins_notify(ld->plugins, take(n)); } - -/* TODO: It's a dummy notification. Will be removed when we have a 'real' one - * in this file. */ -REGISTER_JSON_INTERNAL_COMMAND(hello_notification, NULL, void *);