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

Function is_peer_error

common/read_peer_msg.c:15–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <wire/wire_sync.h>
14
15bool is_peer_error(const tal_t *ctx, const u8 *msg,
16 const struct channel_id *channel_id,
17 char **desc, bool *warning)
18{
19 struct channel_id err_chanid;
20
21 if (fromwire_peektype(msg) == WIRE_ERROR)
22 *warning = false;
23 else if (fromwire_peektype(msg) == WIRE_WARNING)
24 *warning = true;
25 else
26 return false;
27
28 *desc = sanitize_error(ctx, msg, &err_chanid);
29
30 /* BOLT #1:
31 *
32 * The channel is referred to by `channel_id`, unless `channel_id` is
33 * 0 (i.e. all bytes are 0), in which case it refers to all channels.
34 * ...
35 * The receiving node:
36 * - upon receiving `error`:
37 * - if `channel_id` is all zero:
38 * - MUST fail all channels with the sending node.
39 * - otherwise:
40 * - MUST fail the channel referred to by `channel_id`, if that channel is with the sending node.
41 * - upon receiving `warning`:
42 * - SHOULD log the message for later diagnosis.
43 * - MAY disconnect.
44 * - MAY reconnect after some delay to retry.
45 * - MAY attempt `shutdown` if permitted at this point.
46 * - if no existing channel is referred to by `channel_id`:
47 * - MUST ignore the message.
48 */
49
50 /* FIXME: We don't actually free all channels at once, they'll
51 * have to error each in turn. */
52 if (!channel_id_is_all(&err_chanid)
53 && !channel_id_eq(&err_chanid, channel_id))
54 *desc = tal_free(*desc);
55
56 return true;
57}
58
59bool is_wrong_channel(const u8 *msg, const struct channel_id *expected,
60 struct channel_id *actual)

Callers 3

handle_peer_errorFunction · 0.85
opening_negotiate_msgFunction · 0.85
opening_negotiate_msgFunction · 0.85

Calls 4

channel_id_is_allFunction · 0.85
tal_freeFunction · 0.85
sanitize_errorFunction · 0.70
fromwire_peektypeFunction · 0.50

Tested by

no test coverage detected