mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-28 03:14:26 +01:00
lightningd/notification: add 'channel_opened' notification
This notification is sent when a peer succesfully opens a channel to us
This commit is contained in:
committed by
Christian Decker
parent
f55d29ee49
commit
736651ba43
@@ -6,7 +6,8 @@ const char *notification_topics[] = {
|
||||
"connect",
|
||||
"disconnect",
|
||||
"warning",
|
||||
"invoice_payment"
|
||||
"invoice_payment",
|
||||
"channel_opened"
|
||||
};
|
||||
|
||||
bool notifications_have_topic(const char *topic)
|
||||
@@ -76,3 +77,19 @@ void notify_invoice_payment(struct lightningd *ld, struct amount_msat amount,
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
|
||||
void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
|
||||
struct amount_sat *funding_sat, struct bitcoin_txid *funding_txid,
|
||||
bool *funding_locked)
|
||||
{
|
||||
struct jsonrpc_notification *n =
|
||||
jsonrpc_notification_start(NULL, "channel_opened");
|
||||
json_object_start(n->stream, "channel_opened");
|
||||
json_add_node_id(n->stream, "id", node_id);
|
||||
json_add_amount_sat_only(n->stream, "amount", *funding_sat);
|
||||
json_add_txid(n->stream, "funding_txid", funding_txid);
|
||||
json_add_bool(n->stream, "funding_locked", funding_locked);
|
||||
json_object_end(n->stream);
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#ifndef LIGHTNING_LIGHTNINGD_NOTIFICATION_H
|
||||
#define LIGHTNING_LIGHTNINGD_NOTIFICATION_H
|
||||
#include "config.h"
|
||||
#include <bitcoin/short_channel_id.h>
|
||||
#include <bitcoin/tx.h>
|
||||
#include <ccan/json_escape/json_escape.h>
|
||||
#include <common/amount.h>
|
||||
#include <common/node_id.h>
|
||||
#include <lightningd/jsonrpc.h>
|
||||
#include <lightningd/lightningd.h>
|
||||
#include <lightningd/log.h>
|
||||
@@ -19,4 +22,8 @@ void notify_warning(struct lightningd *ld, struct log_entry *l);
|
||||
void notify_invoice_payment(struct lightningd *ld, struct amount_msat amount,
|
||||
struct preimage preimage, const struct json_escape *label);
|
||||
|
||||
void notify_channel_opened(struct lightningd *ld, struct node_id *node_id,
|
||||
struct amount_sat *funding_sat, struct bitcoin_txid *funding_txid,
|
||||
bool *funding_locked);
|
||||
|
||||
#endif /* LIGHTNING_LIGHTNINGD_NOTIFICATION_H */
|
||||
|
||||
@@ -659,6 +659,10 @@ static void opening_fundee_finished(struct subd *openingd,
|
||||
|
||||
channel_watch_funding(ld, channel);
|
||||
|
||||
/* Tell plugins about the success */
|
||||
notify_channel_opened(ld, &channel->peer->id, &channel->funding,
|
||||
&channel->funding_txid, &channel->remote_funding_locked);
|
||||
|
||||
/* On to normal operation! */
|
||||
peer_start_channeld(channel, pps, funding_signed, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user