MCPcopy Create free account
hub / github.com/ElementsProject/lightning / dualopen_errmsg

Function dualopen_errmsg

lightningd/dual_open_control.c:4362–4483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4360}
4361
4362static void dualopen_errmsg(struct channel *channel,
4363 struct peer_fd *peer_fd,
4364 const char *desc,
4365 const u8 *err_for_them,
4366 bool disconnect,
4367 bool warning)
4368{
4369 /* Clean up any in-progress open attempts */
4370 channel_cleanup_commands(channel, desc);
4371
4372 /* An unsaved channel has nothing to remember (and cannot have
4373 * sent tx_signatures). */
4374 if (channel_state_uncommitted(channel->state)) {
4375 forget_channel_open(channel, "Unsaved peer failed");
4376 return;
4377 }
4378 if ((warning || disconnect)
4379 && channel_state_open_uncommitted(channel->state)
4380 && !channel_funding_sigs_sent(channel)) {
4381 forget_channel_open(channel, "Commit ready peer failed");
4382 return;
4383 }
4384
4385 /* Do we have an error to send? */
4386 if (err_for_them && !channel->error && !warning)
4387 channel->error = tal_dup_talarr(channel, u8, err_for_them);
4388
4389 /* No peer_fd means a subd crash or disconnection. */
4390 if (!peer_fd) {
4391 if (!warning && disconnect)
4392 channel_fail_permanent(channel,
4393 err_for_them ? REASON_LOCAL : REASON_PROTOCOL,
4394 "%s: %s ERROR %s",
4395 channel->owner->name,
4396 err_for_them ? "sent" : "received", desc);
4397 else
4398 /* If the channel is unsaved, we forget it */
4399 channel_fail_transient(channel, disconnect, "%s: %s",
4400 channel->owner->name, desc);
4401 return;
4402 }
4403
4404 /* Other implementations chose to ignore errors early on. Not
4405 * surprisingly, they now spew out spurious errors frequently,
4406 * and we would close the channel on them. We now support warnings
4407 * for this case. */
4408 if (warning || !disconnect) {
4409 /* We *don't* hang up if they aborted: that's fine! */
4410 channel_fail_transient(channel, disconnect, "%s %s: %s",
4411 channel->owner->name,
4412 warning ? "WARNING" : "ABORTED",
4413 desc);
4414
4415 /* If it was an abort AND the last infight has no last_tx,
4416 * clean up the inflight. only hits for RBF cases */
4417 if (maybe_cleanup_last_inflight(channel))
4418 log_debug(channel->log, "Cleaned up incomplete inflight");
4419

Callers

nothing calls this directly

Calls 11

forget_channel_openFunction · 0.85
log_infoClass · 0.85
restart_dualopendFunction · 0.85
channel_cleanup_commandsFunction · 0.70
channel_fail_permanentFunction · 0.70
channel_fail_transientFunction · 0.70
channel_fail_forgetFunction · 0.70

Tested by

no test coverage detected