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

Function handle_final_failure

plugins/libplugin-pay.c:1142–1247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1140}
1141
1142static struct command_result *
1143handle_final_failure(struct command *cmd,
1144 struct payment *p,
1145 const struct node_id *final_id,
1146 enum onion_wire failcode)
1147{
1148 u32 unused;
1149
1150 /* Need to check for blockheight disagreement case here,
1151 * otherwise we would set the abort flag too eagerly.
1152 */
1153 if (failure_is_blockheight_disagreement(p, &unused)) {
1154 paymod_log(p, LOG_DBG,
1155 "Blockheight disagreement, not aborting.");
1156 goto nonerror;
1157 }
1158
1159 paymod_log(p, LOG_DBG,
1160 "Final node %s reported %04x (%s) on route %s",
1161 type_to_string(tmpctx, struct node_id, final_id),
1162 failcode, onion_wire_name(failcode),
1163 p->routetxt);
1164
1165 /* We use an exhaustive switch statement here so you get a compile
1166 * warning when new ones are added, and can think about where they go */
1167 switch (failcode) {
1168 case WIRE_FINAL_INCORRECT_CLTV_EXPIRY:
1169 report_tampering(p, tal_count(p->route)-1, "cltv");
1170 goto error;
1171 case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:
1172 report_tampering(p, tal_count(p->route)-1, "amount");
1173 goto error;
1174
1175 /* BOLT #4:
1176 *
1177 * A _forwarding node_ MAY, but a _final node_ MUST NOT:
1178 *...
1179 * - return an `invalid_onion_version` error.
1180 *...
1181 * - return an `invalid_onion_hmac` error.
1182 *...
1183 * - return an `invalid_onion_key` error.
1184 *...
1185 * - return a `temporary_channel_failure` error.
1186 *...
1187 * - return a `permanent_channel_failure` error.
1188 *...
1189 * - return a `required_channel_feature_missing` error.
1190 *...
1191 * - return an `unknown_next_peer` error.
1192 *...
1193 * - return an `amount_below_minimum` error.
1194 *...
1195 * - return a `fee_insufficient` error.
1196 *...
1197 * - return an `incorrect_cltv_expiry` error.
1198 *...
1199 * - return an `expiry_too_soon` error.

Callers 1

Calls 9

paymod_logFunction · 0.85
onion_wire_nameFunction · 0.85
report_tamperingFunction · 0.85
describe_failcodeFunction · 0.85
payment_rootFunction · 0.85
payment_failFunction · 0.85
command_still_pendingFunction · 0.70
type_to_stringClass · 0.50

Tested by

no test coverage detected