diff --git a/lightningd/plugin_hook.c b/lightningd/plugin_hook.c index 1040a41e6..cefea2365 100644 --- a/lightningd/plugin_hook.c +++ b/lightningd/plugin_hook.c @@ -1,12 +1,14 @@ #include #include #include +#include /* Struct containing all the information needed to deserialize and * dispatch an eventual plugin_hook response. */ struct plugin_hook_request { const struct plugin_hook *hook; void *cb_arg; + struct db *db; }; static struct plugin_hook *plugin_hook_by_name(const char *name) @@ -51,7 +53,9 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks, { const jsmntok_t *resulttok = json_get_member(buffer, toks, "result"); void *response = r->hook->deserialize_response(r, buffer, resulttok); + db_begin_transaction(r->db); r->hook->response_cb(r->cb_arg, response); + db_commit_transaction(r->db); tal_free(r); } @@ -71,6 +75,7 @@ void plugin_hook_call_(struct lightningd *ld, const struct plugin_hook *hook, plugin_hook_callback, ph_req); ph_req->hook = hook; ph_req->cb_arg = cb_arg; + ph_req->db = ld->wallet->db; hook->serialize_payload(payload, req->stream); jsonrpc_request_end(req); plugin_request_send(hook->plugin, req);