mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
fundchannel: cancel the fundchannel request if error
If txprepare hits an error, we need to cancel the pending request with our peer.
This commit is contained in:
parent
03a30c0981
commit
f155c61bdf
@ -211,6 +211,27 @@ static struct command_result *tx_prepare_done(struct command *cmd,
|
||||
take(ret));
|
||||
}
|
||||
|
||||
static struct command_result *cancel_start(struct command *cmd,
|
||||
const char *buf,
|
||||
const jsmntok_t *error,
|
||||
struct funding_req *fr)
|
||||
{
|
||||
struct json_out *ret;
|
||||
|
||||
/* We stash the error so we can return it after we've cleaned up */
|
||||
fr->error = json_strdup(fr, buf, error);
|
||||
|
||||
ret = json_out_new(NULL);
|
||||
json_out_start(ret, NULL, '{');
|
||||
json_out_addstr(ret, "id", type_to_string(tmpctx, struct node_id, fr->id));
|
||||
json_out_end(ret, '}');
|
||||
|
||||
return send_outreq(cmd, "fundchannel_cancel",
|
||||
send_prior, send_prior,
|
||||
cast_const(struct funding_req *, fr),
|
||||
take(ret));
|
||||
}
|
||||
|
||||
static struct command_result *fundchannel_start_done(struct command *cmd,
|
||||
const char *buf,
|
||||
const jsmntok_t *result,
|
||||
@ -244,7 +265,7 @@ static struct command_result *fundchannel_start_done(struct command *cmd,
|
||||
json_out_end(ret, '}');
|
||||
|
||||
return send_outreq(cmd, "txprepare",
|
||||
tx_prepare_done, forward_error,
|
||||
tx_prepare_done, cancel_start,
|
||||
cast_const(struct funding_req *, fr),
|
||||
take(ret));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user