mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
plugins/pay: fix leak on failed new payments.
Start with attaching the payment to cmd (in case of failure), then steal onto the plugin itself. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
639eddf840
commit
92f2461b5d
2 changed files with 7 additions and 3 deletions
|
@ -113,7 +113,6 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
bool *use_shadow;
|
bool *use_shadow;
|
||||||
#endif
|
#endif
|
||||||
p = payment_new(NULL, cmd, NULL /* No parent */, pay_mods);
|
|
||||||
if (!param(cmd, buf, params,
|
if (!param(cmd, buf, params,
|
||||||
p_req("destination", param_node_id, &destination),
|
p_req("destination", param_node_id, &destination),
|
||||||
p_req("msatoshi", param_msat, &msat),
|
p_req("msatoshi", param_msat, &msat),
|
||||||
|
@ -130,6 +129,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
||||||
NULL))
|
NULL))
|
||||||
return command_param_failed();
|
return command_param_failed();
|
||||||
|
|
||||||
|
p = payment_new(cmd, cmd, NULL /* No parent */, pay_mods);
|
||||||
p->local_id = &my_id;
|
p->local_id = &my_id;
|
||||||
p->json_buffer = tal_steal(p, buf);
|
p->json_buffer = tal_steal(p, buf);
|
||||||
p->json_toks = params;
|
p->json_toks = params;
|
||||||
|
@ -159,6 +159,8 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
||||||
#endif
|
#endif
|
||||||
p->label = tal_steal(p, label);
|
p->label = tal_steal(p, label);
|
||||||
payment_start(p);
|
payment_start(p);
|
||||||
|
/* We're keeping this around now */
|
||||||
|
tal_steal(cmd->plugin, p);
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1960,8 +1960,6 @@ static struct command_result *json_paymod(struct command *cmd,
|
||||||
bool *use_shadow;
|
bool *use_shadow;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p = payment_new(NULL, cmd, NULL /* No parent */, paymod_mods);
|
|
||||||
|
|
||||||
/* If any of the modifiers need to add params to the JSON-RPC call we
|
/* If any of the modifiers need to add params to the JSON-RPC call we
|
||||||
* would add them to the `param()` call below, and have them be
|
* would add them to the `param()` call below, and have them be
|
||||||
* initialized directly that way. */
|
* initialized directly that way. */
|
||||||
|
@ -1982,6 +1980,8 @@ static struct command_result *json_paymod(struct command *cmd,
|
||||||
NULL))
|
NULL))
|
||||||
return command_param_failed();
|
return command_param_failed();
|
||||||
|
|
||||||
|
p = payment_new(cmd, cmd, NULL /* No parent */, paymod_mods);
|
||||||
|
|
||||||
b11 = bolt11_decode(cmd, b11str, plugin_feature_set(cmd->plugin),
|
b11 = bolt11_decode(cmd, b11str, plugin_feature_set(cmd->plugin),
|
||||||
NULL, chainparams, &fail);
|
NULL, chainparams, &fail);
|
||||||
if (!b11)
|
if (!b11)
|
||||||
|
@ -2057,6 +2057,8 @@ static struct command_result *json_paymod(struct command *cmd,
|
||||||
p->label = tal_steal(p, label);
|
p->label = tal_steal(p, label);
|
||||||
payment_start(p);
|
payment_start(p);
|
||||||
list_add_tail(&payments, &p->list);
|
list_add_tail(&payments, &p->list);
|
||||||
|
/* We're keeping this around now */
|
||||||
|
tal_steal(cmd->plugin, p);
|
||||||
|
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue