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

Function channel_fail_perm

lightningd/channel.c:1071–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1069}
1070
1071static void channel_fail_perm(struct channel *channel,
1072 enum state_change reason,
1073 const char *why,
1074 const struct bitcoin_tx *spent_by)
1075{
1076 struct lightningd *ld = channel->peer->ld;
1077
1078 /* Don't do anything if it's an stub channel because
1079 * peer has already closed it unilatelrally. */
1080 if (channel->scid && is_stub_scid(*channel->scid))
1081 return;
1082
1083 log_unusual(channel->log,
1084 "Peer permanent failure in %s: %s (reason=%s)",
1085 channel_state_name(channel), why,
1086 channel_change_state_reason_str(reason));
1087
1088 /* We can have multiple errors, eg. onchaind failures. */
1089 if (!channel->error)
1090 channel->error = towire_errorfmt(channel,
1091 &channel->cid, "%s", why);
1092
1093 channel_set_owner(channel, NULL);
1094
1095 if (channel_state_wants_onchain_fail(channel->state) && !channel->withheld) {
1096 channel_set_state(channel,
1097 channel->state,
1098 AWAITING_UNILATERAL,
1099 reason,
1100 why);
1101 }
1102
1103 /* BOLT #5:
1104 * A node:
1105 * - if a *local commitment transaction* has NOT ever contained a `to_local`
1106 * or HTLC output:
1107 * - MAY simply forget the channel.
1108 */
1109 /* FIXME: We only implement a subset of this; we keep waiting
1110 * as long as it was finished opening. */
1111 if (channel_state_open_uncommitted(channel->state)) {
1112 delete_channel(channel, false);
1113 return;
1114 }
1115
1116 /* Drop non-cooperatively (unilateral) to chain. If we detect
1117 * the close from the blockchain, then we can observe
1118 * passively, and not broadcast our own unilateral close, as
1119 * it doesn't stand a chance anyway. */
1120 drop_to_chain(ld, channel, false, spent_by);
1121
1122}
1123
1124void channel_fail_permanent(struct channel *channel,
1125 enum state_change reason,

Callers 2

channel_fail_permanentFunction · 0.85
channel_fail_saw_onchainFunction · 0.85

Calls 10

is_stub_scidFunction · 0.85
towire_errorfmtFunction · 0.85
channel_set_ownerFunction · 0.85
channel_set_stateFunction · 0.85
drop_to_chainFunction · 0.85
channel_state_nameFunction · 0.70
delete_channelFunction · 0.70

Tested by

no test coverage detected