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

Function payment_can_retry

plugins/libplugin-pay.c:2496–2543  ·  view source on GitHub ↗

Determine whether retrying could possibly succeed. Retrying in this case * means that we repeat the entire flow, including computing a new route, new * payload and a new sendonion call. It does not mean we retry the exact same * attempt that just failed. */

Source from the content-addressed store, hash-verified

2494 * payload and a new sendonion call. It does not mean we retry the exact same
2495 * attempt that just failed. */
2496static bool payment_can_retry(struct payment *p)
2497{
2498 struct payment_result *res = p->result;
2499 u32 idx;
2500 bool is_final;
2501
2502 if (p->result == NULL)
2503 return p->failroute_retry;
2504
2505 idx = res->erring_index != NULL ? *res->erring_index : 0;
2506 is_final = (idx == tal_count(p->route));
2507
2508 /* Full matrix of failure code x is_final. Prefer to retry once too
2509 * often over eagerly failing. */
2510 switch (res->failcode) {
2511 case WIRE_EXPIRY_TOO_FAR:
2512 case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
2513 case WIRE_INVALID_ONION_PAYLOAD:
2514 case WIRE_INVALID_ONION_VERSION:
2515 case WIRE_MPP_TIMEOUT:
2516 case WIRE_PERMANENT_NODE_FAILURE:
2517 case WIRE_REQUIRED_NODE_FEATURE_MISSING:
2518 case WIRE_TEMPORARY_NODE_FAILURE:
2519 case WIRE_UNKNOWN_NEXT_PEER:
2520 return !is_final;
2521
2522 case WIRE_AMOUNT_BELOW_MINIMUM:
2523 case WIRE_CHANNEL_DISABLED:
2524 case WIRE_EXPIRY_TOO_SOON:
2525 case WIRE_FEE_INSUFFICIENT:
2526 case WIRE_FINAL_INCORRECT_CLTV_EXPIRY:
2527 case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:
2528 case WIRE_INCORRECT_CLTV_EXPIRY:
2529 case WIRE_INVALID_ONION_HMAC:
2530 case WIRE_INVALID_ONION_KEY:
2531 case WIRE_PERMANENT_CHANNEL_FAILURE:
2532 case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:
2533 case WIRE_TEMPORARY_CHANNEL_FAILURE:
2534 case WIRE_INVALID_ONION_BLINDING:
2535 return true;
2536 }
2537
2538 /* We should never get here, otherwise the above `switch` isn't
2539 * exhaustive. Nevertheless the failcode is provided by the erring
2540 * node, so retry anyway. `abort()`ing on externally supplied info is
2541 * not a good idea. */
2542 return true;
2543}
2544
2545static struct command_result *retry_step_cb(struct retry_mod_data *rd,
2546 struct payment *p)

Callers 1

retry_step_cbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected