mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-19 21:14:38 +01:00
plugin: Add connect and disconnect notifications
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include <ccan/array_size/array_size.h>
|
||||
|
||||
const char *notification_topics[] = {
|
||||
"connect",
|
||||
"disconnect",
|
||||
};
|
||||
|
||||
bool notifications_have_topic(const char *topic)
|
||||
@@ -11,3 +13,23 @@ bool notifications_have_topic(const char *topic)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void notify_connect(struct lightningd *ld, struct pubkey *nodeid,
|
||||
struct wireaddr_internal *addr)
|
||||
{
|
||||
struct jsonrpc_notification *n =
|
||||
jsonrpc_notification_start(NULL, notification_topics[0]);
|
||||
json_add_pubkey(n->stream, "id", nodeid);
|
||||
json_add_address_internal(n->stream, "address", addr);
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
|
||||
void notify_disconnect(struct lightningd *ld, struct pubkey *nodeid)
|
||||
{
|
||||
struct jsonrpc_notification *n =
|
||||
jsonrpc_notification_start(NULL, notification_topics[1]);
|
||||
json_add_pubkey(n->stream, "id", nodeid);
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user