mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
plugin: Register channel_opened
notification
This commit is contained in:
parent
2907e430d5
commit
a3eb2942de
@ -5,7 +5,6 @@
|
|||||||
#include <lightningd/peer_htlcs.h>
|
#include <lightningd/peer_htlcs.h>
|
||||||
|
|
||||||
const char *notification_topics[] = {
|
const char *notification_topics[] = {
|
||||||
"channel_opened",
|
|
||||||
"forward_event"
|
"forward_event"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -149,18 +148,36 @@ void notify_invoice_payment(struct lightningd *ld, struct amount_msat amount,
|
|||||||
plugins_notify(ld->plugins, take(n));
|
plugins_notify(ld->plugins, take(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void channel_opened_notification_serialize(struct json_stream *stream,
|
||||||
|
struct node_id *node_id,
|
||||||
|
struct amount_sat *funding_sat,
|
||||||
|
struct bitcoin_txid *funding_txid,
|
||||||
|
bool *funding_locked)
|
||||||
|
{
|
||||||
|
json_object_start(stream, "channel_opened");
|
||||||
|
json_add_node_id(stream, "id", node_id);
|
||||||
|
json_add_amount_sat_only(stream, "amount", *funding_sat);
|
||||||
|
json_add_txid(stream, "funding_txid", funding_txid);
|
||||||
|
json_add_bool(stream, "funding_locked", funding_locked);
|
||||||
|
json_object_end(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_NOTIFICATION(channel_opened,
|
||||||
|
channel_opened_notification_serialize)
|
||||||
|
|
||||||
void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
|
void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
|
||||||
struct amount_sat *funding_sat, struct bitcoin_txid *funding_txid,
|
struct amount_sat *funding_sat, struct bitcoin_txid *funding_txid,
|
||||||
bool *funding_locked)
|
bool *funding_locked)
|
||||||
{
|
{
|
||||||
struct jsonrpc_notification *n =
|
void (*serialize)(struct json_stream *,
|
||||||
jsonrpc_notification_start(NULL, "channel_opened");
|
struct node_id *,
|
||||||
json_object_start(n->stream, "channel_opened");
|
struct amount_sat *,
|
||||||
json_add_node_id(n->stream, "id", node_id);
|
struct bitcoin_txid *,
|
||||||
json_add_amount_sat_only(n->stream, "amount", *funding_sat);
|
bool *) = channel_opened_notification_gen.serialize;
|
||||||
json_add_txid(n->stream, "funding_txid", funding_txid);
|
|
||||||
json_add_bool(n->stream, "funding_locked", funding_locked);
|
struct jsonrpc_notification *n
|
||||||
json_object_end(n->stream);
|
= jsonrpc_notification_start(NULL, channel_opened_notification_gen.topic);
|
||||||
|
serialize(n->stream, node_id, funding_sat, funding_txid, funding_locked);
|
||||||
jsonrpc_notification_end(n);
|
jsonrpc_notification_end(n);
|
||||||
plugins_notify(ld->plugins, take(n));
|
plugins_notify(ld->plugins, take(n));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user