| 1721 | } |
| 1722 | |
| 1723 | static struct command_result *getroutes_done_err(struct command *aux_cmd, |
| 1724 | const char *method, |
| 1725 | const char *buf, |
| 1726 | const jsmntok_t *error, |
| 1727 | struct payment *payment) |
| 1728 | { |
| 1729 | int code; |
| 1730 | const char *msg, *complaint; |
| 1731 | |
| 1732 | /* getroutes gives nice error messages: we may need to annotate though. */ |
| 1733 | msg = json_strdup(tmpctx, buf, json_get_member(buf, error, "message")); |
| 1734 | json_to_int(buf, json_get_member(buf, error, "code"), &code); |
| 1735 | |
| 1736 | /* If we were restricting the number of parts, we remove that |
| 1737 | * restriction and try again. */ |
| 1738 | if (payment->maxparts) { |
| 1739 | payment_log(payment, LOG_INFORM, |
| 1740 | "getroute failed with maxparts=%u, so retrying without that restriction", |
| 1741 | payment->maxparts); |
| 1742 | payment->maxparts = 0; |
| 1743 | return getroutes_for(aux_cmd, payment, payment->amount_being_routed); |
| 1744 | } |
| 1745 | |
| 1746 | /* Simple case: failed immediately. */ |
| 1747 | if (payment->total_num_attempts == 0) { |
| 1748 | payment_give_up(aux_cmd, payment, code, "Failed: %s", msg); |
| 1749 | return command_still_pending(aux_cmd); |
| 1750 | } |
| 1751 | |
| 1752 | /* FIXME: If we fail due to exceeding maxfee, we *could* try waiting for |
| 1753 | * any outstanding payments to fail and then try again? */ |
| 1754 | |
| 1755 | /* More elaborate explanation. */ |
| 1756 | if (amount_msat_eq(payment->amount_being_routed, payment->amount)) |
| 1757 | complaint = "Then routing failed"; |
| 1758 | else |
| 1759 | complaint = tal_fmt(tmpctx, "Then routing for remaining %s failed", |
| 1760 | fmt_amount_msat(tmpctx, payment->amount_being_routed)); |
| 1761 | payment_give_up(aux_cmd, payment, PAY_UNSPECIFIED_ERROR, |
| 1762 | "Failed after %"PRIu64" attempts. %s%s: %s", |
| 1763 | payment->total_num_attempts, |
| 1764 | payment->prior_results, |
| 1765 | complaint, |
| 1766 | msg); |
| 1767 | return command_still_pending(aux_cmd); |
| 1768 | } |
| 1769 | |
| 1770 | static struct command_result *waitblockheight_done(struct command *aux_cmd, |
| 1771 | const char *method, |
nothing calls this directly
no test coverage detected