Browse Source

df: handle fails

We weren't handling failure messages, now we handle them.

Also, fail/kill dualopend if there's a failure.
ppa
niftynei 4 years ago
committed by Christian Decker
parent
commit
ae532614a3
  1. 40
      lightningd/dual_open_control.c
  2. 1
      openingd/dualopend.c

40
lightningd/dual_open_control.c

@ -951,6 +951,44 @@ cleanup:
tal_free(uc);
}
static void
opening_failed_cancel_commands(struct uncommitted_channel *uc,
const char *desc)
{
if (!uc->fc)
return;
/* FIXME: cancels? */
if (uc->fc->cmd)
was_pending(command_fail(uc->fc->cmd, LIGHTNINGD, "%s", desc));
uc->fc = tal_free(uc->fc);
}
static void open_failed(struct subd *dualopend, const u8 *msg)
{
char *desc;
struct uncommitted_channel *uc;
assert(dualopend->ctype == UNCOMMITTED);
uc = dualopend->channel;
if (!fromwire_dualopend_failed(msg, msg, &desc)) {
log_broken(uc->log,
"Bad DUALOPEND_FAILED %s",
tal_hex(msg, msg));
if (uc->fc && uc->fc->cmd)
was_pending(command_fail(uc->fc->cmd, LIGHTNINGD, "%s",
tal_hex(uc->fc->cmd, msg)));
tal_free(uc);
}
opening_failed_cancel_commands(uc, desc);
}
struct channel_send {
const struct wally_tx *wtx;
struct channel *channel;
@ -1624,6 +1662,8 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
handle_channel_locked(dualopend, fds, msg);
return 0;
case WIRE_DUALOPEND_FAILED:
open_failed(dualopend, msg);
return 0;
case WIRE_DUALOPEND_DEV_MEMLEAK_REPLY:
/* Messages we send */

1
openingd/dualopend.c

@ -1452,6 +1452,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
u8 *errmsg = towire_errorfmt(tmpctx, &state->channel_id,
"%s", err_reason);
sync_crypto_write(state->pps, take(errmsg));
status_failed(STATUS_FAIL_MASTER_IO, "%s", errmsg);
return;
}
if (!fromwire_dualopend_got_offer_reply(state, msg,

Loading…
Cancel
Save