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

Function dualopen_errmsg

lightningd/dual_open_control.c:4000–4118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3998AUTODATA(json_command, &openchannel_abort_command);
3999
4000static void dualopen_errmsg(struct channel *channel,
4001 struct peer_fd *peer_fd,
4002 const char *desc,
4003 const u8 *err_for_them,
4004 bool disconnect,
4005 bool warning)
4006{
4007 /* Clean up any in-progress open attempts */
4008 channel_cleanup_commands(channel, desc);
4009
4010 if (channel_state_uncommitted(channel->state)) {
4011 log_info(channel->log, "%s", "Unsaved peer failed."
4012 " Deleting channel.");
4013 delete_channel(channel, false);
4014 return;
4015 }
4016 if ((warning || disconnect) && channel_state_open_uncommitted(channel->state)) {
4017 log_info(channel->log, "%s", "Commit ready peer failed."
4018 " Deleting channel.");
4019 delete_channel(channel, false);
4020 return;
4021 }
4022
4023 /* Do we have an error to send? */
4024 if (err_for_them && !channel->error && !warning)
4025 channel->error = tal_dup_talarr(channel, u8, err_for_them);
4026
4027 /* No peer_fd means a subd crash or disconnection. */
4028 if (!peer_fd) {
4029 if (!warning && disconnect)
4030 channel_fail_permanent(channel,
4031 err_for_them ? REASON_LOCAL : REASON_PROTOCOL,
4032 "%s: %s ERROR %s",
4033 channel->owner->name,
4034 err_for_them ? "sent" : "received", desc);
4035 else
4036 /* If the channel is unsaved, we forget it */
4037 channel_fail_transient(channel, disconnect, "%s: %s",
4038 channel->owner->name, desc);
4039 return;
4040 }
4041
4042 /* Other implementations chose to ignore errors early on. Not
4043 * surprisingly, they now spew out spurious errors frequently,
4044 * and we would close the channel on them. We now support warnings
4045 * for this case. */
4046 if (warning || !disconnect) {
4047 /* We *don't* hang up if they aborted: that's fine! */
4048 channel_fail_transient(channel, disconnect, "%s %s: %s",
4049 channel->owner->name,
4050 warning ? "WARNING" : "ABORTED",
4051 desc);
4052
4053 /* If it was an abort AND the last infight has no last_tx,
4054 * clean up the inflight. only hits for RBF cases */
4055 if (maybe_cleanup_last_inflight(channel))
4056 log_debug(channel->log, "Cleaned up incomplete inflight");
4057

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected