diff --git a/plugins/txprepare.c b/plugins/txprepare.c index 84da4161a..b20f2c934 100644 --- a/plugins/txprepare.c +++ b/plugins/txprepare.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -212,6 +213,8 @@ static struct command_result *finish_txprepare(struct command *cmd, if (txp->is_withdraw) { struct out_req *req; + /* Won't live beyond this cmd. */ + tal_steal(cmd, utx); req = jsonrpc_request_start(cmd->plugin, cmd, "signpsbt", signpsbt_done, forward_error, utx); @@ -558,9 +561,25 @@ static const struct plugin_command commands[] = { }, }; +#if DEVELOPER +static void mark_unreleased_txs(struct plugin *plugin, struct htable *memtable) +{ + memleak_remove_region(memtable, &unreleased_txs, sizeof(unreleased_txs)); +} +#endif + +static const char *init(struct plugin *p, + const char *buf UNUSED, const jsmntok_t *config UNUSED) +{ +#if DEVELOPER + plugin_set_memleak_handler(p, mark_unreleased_txs); +#endif + return NULL; +} + int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, NULL, PLUGIN_RESTARTABLE, true, NULL, commands, + plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL, commands, ARRAY_SIZE(commands), NULL, 0, NULL, 0, NULL, 0, NULL); }