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. */
| 2201 | * payload and a new sendonion call. It does not mean we retry the exact same |
| 2202 | * attempt that just failed. */ |
| 2203 | static bool payment_can_retry(struct payment *p) |
| 2204 | { |
| 2205 | struct payment_result *res = p->result; |
| 2206 | u32 idx; |
| 2207 | bool is_final; |
| 2208 | |
| 2209 | if (p->result == NULL) |
| 2210 | return p->failroute_retry; |
| 2211 | |
| 2212 | idx = res->erring_index != NULL ? *res->erring_index : 0; |
| 2213 | is_final = (idx == tal_count(p->route)); |
| 2214 | |
| 2215 | /* Full matrix of failure code x is_final. Prefer to retry once too |
| 2216 | * often over eagerly failing. */ |
| 2217 | switch (res->failcode) { |
| 2218 | case WIRE_EXPIRY_TOO_FAR: |
| 2219 | case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS: |
| 2220 | case WIRE_INVALID_ONION_PAYLOAD: |
| 2221 | case WIRE_INVALID_ONION_VERSION: |
| 2222 | case WIRE_INVALID_REALM: |
| 2223 | case WIRE_MPP_TIMEOUT: |
| 2224 | case WIRE_PERMANENT_NODE_FAILURE: |
| 2225 | case WIRE_REQUIRED_NODE_FEATURE_MISSING: |
| 2226 | case WIRE_TEMPORARY_NODE_FAILURE: |
| 2227 | case WIRE_UNKNOWN_NEXT_PEER: |
| 2228 | return !is_final; |
| 2229 | |
| 2230 | case WIRE_AMOUNT_BELOW_MINIMUM: |
| 2231 | case WIRE_CHANNEL_DISABLED: |
| 2232 | case WIRE_EXPIRY_TOO_SOON: |
| 2233 | case WIRE_FEE_INSUFFICIENT: |
| 2234 | case WIRE_FINAL_INCORRECT_CLTV_EXPIRY: |
| 2235 | case WIRE_FINAL_INCORRECT_HTLC_AMOUNT: |
| 2236 | case WIRE_INCORRECT_CLTV_EXPIRY: |
| 2237 | case WIRE_INVALID_ONION_HMAC: |
| 2238 | case WIRE_INVALID_ONION_KEY: |
| 2239 | case WIRE_PERMANENT_CHANNEL_FAILURE: |
| 2240 | case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING: |
| 2241 | case WIRE_TEMPORARY_CHANNEL_FAILURE: |
| 2242 | #if EXPERIMENTAL_FEATURES |
| 2243 | case WIRE_INVALID_ONION_BLINDING: |
| 2244 | #endif |
| 2245 | return true; |
| 2246 | } |
| 2247 | |
| 2248 | /* We should never get here, otherwise the above `switch` isn't |
| 2249 | * exhaustive. Nevertheless the failcode is provided by the erring |
| 2250 | * node, so retry anyway. `abort()`ing on externally supplied info is |
| 2251 | * not a good idea. */ |
| 2252 | return true; |
| 2253 | } |
| 2254 | |
| 2255 | static inline void retry_step_cb(struct retry_mod_data *rd, |
| 2256 | struct payment *p) |