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

Function handle_intermediate_failure

plugins/libplugin-pay.c:1410–1510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1408}
1409
1410static struct command_result *
1411handle_intermediate_failure(struct command *cmd,
1412 struct payment *p,
1413 const struct node_id *errnode,
1414 const struct route_hop *errchan,
1415 enum onion_wire failcode)
1416{
1417 struct payment *root = payment_root(p);
1418 struct amount_msat estimated;
1419
1420 paymod_log(p, LOG_DBG,
1421 "Intermediate node %s reported %04x (%s) at %s on route %s",
1422 fmt_node_id(tmpctx, errnode),
1423 failcode, onion_wire_name(failcode),
1424 fmt_short_channel_id(tmpctx, errchan->scid),
1425 p->routetxt);
1426
1427 /* We use an exhaustive switch statement here so you get a compile
1428 * warning when new ones are added, and can think about where they go */
1429 switch (failcode) {
1430 /* BOLT #4:
1431 *
1432 * An _intermediate hop_ MUST NOT, but the _final node_:
1433 *...
1434 * - MUST return an `incorrect_or_unknown_payment_details` error.
1435 *...
1436 * - MUST return `final_incorrect_cltv_expiry` error.
1437 *...
1438 * - MUST return a `final_incorrect_htlc_amount` error.
1439 */
1440 case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
1441 case WIRE_FINAL_INCORRECT_CLTV_EXPIRY:
1442 case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:
1443 /* FIXME: Document in BOLT that intermediates must not return this! */
1444 case WIRE_MPP_TIMEOUT:
1445 goto strange_error;
1446
1447 case WIRE_PERMANENT_CHANNEL_FAILURE:
1448 case WIRE_CHANNEL_DISABLED:
1449 case WIRE_UNKNOWN_NEXT_PEER:
1450 case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:
1451 /* All of these result in the channel being marked as disabled. */
1452 channel_hints_update(root, errchan->scid, errchan->direction,
1453 false, false, NULL, errchan->capacity,
1454 NULL);
1455 break;
1456
1457 case WIRE_TEMPORARY_CHANNEL_FAILURE: {
1458 memcheck(&errchan->amount, sizeof(struct amount_msat));
1459 estimated = errchan->amount;
1460
1461 /* Subtract one msat more, since we know that the amount did not
1462 * work. This allows us to then allow on equality, this is for
1463 * example necessary for local channels where exact matches
1464 * should be allowed. */
1465 if (!amount_msat_deduct(&estimated, AMOUNT_MSAT(1)))
1466 abort();
1467

Callers 1

Calls 11

payment_rootFunction · 0.85
paymod_logFunction · 0.85
fmt_node_idFunction · 0.85
fmt_short_channel_idFunction · 0.85
channel_hints_updateFunction · 0.85
amount_msat_deductFunction · 0.85
abortFunction · 0.85
report_tamperingFunction · 0.85
disable_if_dyingFunction · 0.85
describe_failcodeFunction · 0.85
payment_failFunction · 0.70

Tested by

no test coverage detected