Browse Source

fundchannel: cancel the fundchannel request if error

If txprepare hits an error, we need to cancel the pending request
with our peer.
travis-debug
lisa neigut 5 years ago
committed by Rusty Russell
parent
commit
f155c61bdf
  1. 23
      plugins/fundchannel.c

23
plugins/fundchannel.c

@ -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…
Cancel
Save