funder: use auxilliary command instead of NULL command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -73,7 +73,7 @@ new_channel_open(const tal_t *ctx,
|
||||
}
|
||||
|
||||
static struct command_result *
|
||||
unreserve_done(struct command *cmd UNUSED,
|
||||
unreserve_done(struct command *aux_cmd,
|
||||
const char *buf,
|
||||
const jsmntok_t *result,
|
||||
struct pending_open *open)
|
||||
@@ -84,21 +84,24 @@ unreserve_done(struct command *cmd UNUSED,
|
||||
json_tok_full_len(result),
|
||||
json_tok_full(buf, result));
|
||||
|
||||
tal_free(open);
|
||||
return command_done();
|
||||
return aux_command_done(aux_cmd);
|
||||
}
|
||||
|
||||
/* Frees open (eventually, in unreserve_done callback) */
|
||||
static void unreserve_psbt(struct pending_open *open)
|
||||
static struct command_result *unreserve_psbt(struct command *cmd,
|
||||
struct pending_open *open)
|
||||
{
|
||||
struct out_req *req;
|
||||
struct command *aux;
|
||||
|
||||
plugin_log(open->p, LOG_DBG,
|
||||
"Calling `unreserveinputs` for channel %s",
|
||||
fmt_channel_id(tmpctx,
|
||||
&open->channel_id));
|
||||
|
||||
req = jsonrpc_request_start(open->p, NULL,
|
||||
/* This can outlive the underlying cmd, so use an aux! */
|
||||
aux = aux_command(cmd);
|
||||
req = jsonrpc_request_start(open->p, aux,
|
||||
"unreserveinputs",
|
||||
unreserve_done, unreserve_done,
|
||||
open);
|
||||
@@ -108,15 +111,18 @@ static void unreserve_psbt(struct pending_open *open)
|
||||
/* We will free this in callback, but remove from list *now*
|
||||
* to avoid calling twice! */
|
||||
list_del_from(&pending_opens, &open->list);
|
||||
notleak(open);
|
||||
tal_steal(aux, open);
|
||||
|
||||
return command_still_pending(aux);
|
||||
}
|
||||
|
||||
static void cleanup_peer_pending_opens(const struct node_id *id)
|
||||
static void cleanup_peer_pending_opens(struct command *cmd,
|
||||
const struct node_id *id)
|
||||
{
|
||||
struct pending_open *i, *next;
|
||||
list_for_each_safe(&pending_opens, i, next, list) {
|
||||
if (node_id_eq(&i->peer_id, id)) {
|
||||
unreserve_psbt(i);
|
||||
unreserve_psbt(cmd, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1088,7 +1094,7 @@ static struct command_result *json_disconnect(struct command *cmd,
|
||||
"Cleaning up inflights for peer id %s",
|
||||
fmt_node_id(tmpctx, &id));
|
||||
|
||||
cleanup_peer_pending_opens(&id);
|
||||
cleanup_peer_pending_opens(cmd, &id);
|
||||
|
||||
return notification_handled(cmd);
|
||||
}
|
||||
@@ -1176,7 +1182,7 @@ static struct command_result *json_channel_open_failed(struct command *cmd,
|
||||
|
||||
open = find_channel_pending_open(&cid);
|
||||
if (open)
|
||||
unreserve_psbt(open);
|
||||
unreserve_psbt(cmd, open);
|
||||
|
||||
/* Also clean up datastore for this channel */
|
||||
return delete_channel_from_datastore(cmd, &cid);
|
||||
|
||||
Reference in New Issue
Block a user