diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 8da97f282..ac9e1f6ef 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -188,9 +188,9 @@ struct rbf_channel_payload { char *err_msg; }; -static void -rbf_channel_hook_serialize(struct rbf_channel_payload *payload, - struct json_stream *stream) +static void rbf_channel_hook_serialize(struct rbf_channel_payload *payload, + struct json_stream *stream, + struct plugin *plugin) { json_object_start(stream, "rbf_channel"); json_add_node_id(stream, "id", &payload->peer_id); @@ -251,9 +251,9 @@ struct openchannel2_payload { char *err_msg; }; -static void -openchannel2_hook_serialize(struct openchannel2_payload *payload, - struct json_stream *stream) +static void openchannel2_hook_serialize(struct openchannel2_payload *payload, + struct json_stream *stream, + struct plugin *plugin) { json_object_start(stream, "openchannel2"); json_add_node_id(stream, "id", &payload->peer_id); @@ -295,7 +295,8 @@ struct openchannel2_psbt_payload { static void openchannel2_changed_hook_serialize(struct openchannel2_psbt_payload *payload, - struct json_stream *stream) + struct json_stream *stream, + struct plugin *plugin) { json_object_start(stream, "openchannel2_changed"); json_add_psbt(stream, "psbt", payload->psbt); @@ -307,7 +308,8 @@ openchannel2_changed_hook_serialize(struct openchannel2_psbt_payload *payload, static void openchannel2_sign_hook_serialize(struct openchannel2_psbt_payload *payload, - struct json_stream *stream) + struct json_stream *stream, + struct plugin *plugin) { json_object_start(stream, "openchannel2_sign"); json_add_psbt(stream, "psbt", payload->psbt); diff --git a/lightningd/invoice.c b/lightningd/invoice.c index d3f4744bb..56b42a10e 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -169,7 +169,8 @@ struct invoice_payment_hook_payload { static void invoice_payment_serialize(struct invoice_payment_hook_payload *payload, - struct json_stream *stream) + struct json_stream *stream, + struct plugin *plugin) { json_object_start(stream, "payment"); json_add_escaped_string(stream, "label", payload->label); diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 1d42e0f22..1859325b2 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -674,7 +674,8 @@ struct rpc_command_hook_payload { }; static void rpc_command_hook_serialize(struct rpc_command_hook_payload *p, - struct json_stream *s) + struct json_stream *s, + struct plugin *plugin) { const jsmntok_t *tok; size_t i; diff --git a/lightningd/onion_message.c b/lightningd/onion_message.c index 7b668b77c..fa8bcf1a1 100644 --- a/lightningd/onion_message.c +++ b/lightningd/onion_message.c @@ -15,9 +15,9 @@ struct onion_message_hook_payload { struct tlv_onionmsg_payload *om; }; -static void -onion_message_serialize(struct onion_message_hook_payload *payload, - struct json_stream *stream) +static void onion_message_serialize(struct onion_message_hook_payload *payload, + struct json_stream *stream, + struct plugin *plugin) { json_object_start(stream, "onion_message"); if (payload->blinding_in) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 7a1ffe91e..394b64525 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -615,9 +615,9 @@ struct openchannel_hook_payload { char *errmsg; }; -static void -openchannel_hook_serialize(struct openchannel_hook_payload *payload, - struct json_stream *stream) +static void openchannel_hook_serialize(struct openchannel_hook_payload *payload, + struct json_stream *stream, + struct plugin *plugin) { struct uncommitted_channel *uc = payload->openingd->channel; json_object_start(stream, "openchannel"); diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 86d2c6999..b2d083e0e 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1039,7 +1039,7 @@ struct peer_connected_hook_payload { static void peer_connected_serialize(struct peer_connected_hook_payload *payload, - struct json_stream *stream) + struct json_stream *stream, struct plugin *plugin) { const struct peer *p = payload->peer; json_object_start(stream, "peer"); @@ -2782,7 +2782,8 @@ static void custommsg_final(struct custommsg_payload *payload STEALS) } static void custommsg_payload_serialize(struct custommsg_payload *payload, - struct json_stream *stream) + struct json_stream *stream, + struct plugin *plugin) { /* Backward compat for broken custommsg: if we get a custommsg * from an old c-lightning node, then we must identify and diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index c2ac7cdf7..041df8d3d 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1011,7 +1011,8 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re } static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p, - struct json_stream *s) + struct json_stream *s, + struct plugin *plugin) { const struct route_step *rs = p->route_step; const struct htlc_in *hin = p->hin; @@ -2034,7 +2035,8 @@ struct commitment_revocation_payload { }; static void commitment_revocation_hook_serialize( - struct commitment_revocation_payload *payload, struct json_stream *stream) + struct commitment_revocation_payload *payload, struct json_stream *stream, + struct plugin *plugin) { json_add_txid(stream, "commitment_txid", &payload->commitment_txid); json_add_tx(stream, "penalty_tx", payload->penalty_tx); diff --git a/lightningd/plugin_hook.c b/lightningd/plugin_hook.c index 2ad73341b..e5a3cbbff 100644 --- a/lightningd/plugin_hook.c +++ b/lightningd/plugin_hook.c @@ -232,7 +232,7 @@ static void plugin_hook_call_next(struct plugin_hook_request *ph_req) NULL, plugin_hook_callback, ph_req); - hook->serialize_payload(ph_req->cb_arg, req->stream); + hook->serialize_payload(ph_req->cb_arg, req->stream, ph_req->plugin); jsonrpc_request_end(req); plugin_request_send(ph_req->plugin, req); } diff --git a/lightningd/plugin_hook.h b/lightningd/plugin_hook.h index f746ee19e..7279dc5bf 100644 --- a/lightningd/plugin_hook.h +++ b/lightningd/plugin_hook.h @@ -49,7 +49,8 @@ struct plugin_hook { void (*final_cb)(void *arg); /* To send the payload to the plugin */ - void (*serialize_payload)(void *src, struct json_stream *dest); + void (*serialize_payload)(void *src, struct json_stream *dest, + struct plugin *plugin); /* Which plugins have registered this hook? This is a `tal_arr` * initialized at creation. */ @@ -91,20 +92,19 @@ bool plugin_hook_continue(void *arg, const char *buffer, const jsmntok_t *toks); * an arbitrary extra argument used to maintain context. */ #define REGISTER_PLUGIN_HOOK(name, deserialize_cb, final_cb, \ - serialize_payload, cb_arg_type) \ + serialize_payload, cb_arg_type) \ struct plugin_hook name##_hook_gen = { \ stringify(name), \ typesafe_cb_cast( \ bool (*)(void *, const char *, const jsmntok_t *), \ bool (*)(cb_arg_type, const char *, const jsmntok_t *), \ deserialize_cb), \ + typesafe_cb_cast(void (*)(void *STEALS), \ + void (*)(cb_arg_type STEALS), final_cb), \ typesafe_cb_cast( \ - void (*)(void *STEALS), \ - void (*)(cb_arg_type STEALS), \ - final_cb), \ - typesafe_cb_cast(void (*)(void *, struct json_stream *), \ - void (*)(cb_arg_type, struct json_stream *), \ - serialize_payload), \ + void (*)(void *, struct json_stream *, struct plugin *), \ + void (*)(cb_arg_type, struct json_stream *, struct plugin *), \ + serialize_payload), \ NULL, /* .plugins */ \ }; \ AUTODATA(hooks, &name##_hook_gen); \