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

Function handle_intermediate_failure

plugins/libplugin-pay.c:1398–1494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 10

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
describe_failcodeFunction · 0.85
payment_failFunction · 0.70

Tested by

no test coverage detected