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

Function channel_errmsg

lightningd/peer_control.c:347–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347void channel_errmsg(struct channel *channel,
348 struct peer_fd *peer_fd,
349 const struct channel_id *channel_id UNUSED,
350 const char *desc,
351 bool warning,
352 const u8 *err_for_them)
353{
354 /* Clean up any in-progress open attempts */
355 channel_cleanup_commands(channel, desc);
356
357 if (channel_unsaved(channel)) {
358 log_info(channel->log, "%s", "Unsaved peer failed."
359 " Disconnecting and deleting channel.");
360 delete_channel(channel);
361 return;
362 }
363
364 /* No peer_fd means a subd crash or disconnection. */
365 if (!peer_fd) {
366 /* If the channel is unsaved, we forget it */
367 channel_fail_transient(channel, "%s: %s",
368 channel->owner->name, desc);
369 return;
370 }
371
372 /* Do we have an error to send? */
373 if (err_for_them && !channel->error && !warning)
374 channel->error = tal_dup_talarr(channel, u8, err_for_them);
375
376 /* Other implementations chose to ignore errors early on. Not
377 * surprisingly, they now spew out spurious errors frequently,
378 * and we would close the channel on them. We now support warnings
379 * for this case. */
380 if (warning) {
381 channel_fail_transient_delayreconnect(channel, "%s WARNING: %s",
382 channel->owner->name, desc);
383 return;
384 }
385
386 /* BOLT #1:
387 *
388 * A sending node:
389 *...
390 * - when sending `error`:
391 * - MUST fail the channel(s) referred to by the error message.
392 * - MAY set `channel_id` to all zero to indicate all channels.
393 */
394 /* FIXME: Close if it's an all-channels error sent or rcvd */
395
396 /* BOLT #1:
397 *
398 * A sending node:
399 *...
400 * - when sending `error`:
401 * - MUST fail the channel(s) referred to by the error message.
402 * - MAY set `channel_id` to all zero to indicate all channels.
403 *...
404 * The receiving node:

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected