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