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

Function getroutes_done_err

plugins/xpay/xpay.c:1723–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1721}
1722
1723static 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
1770static struct command_result *waitblockheight_done(struct command *aux_cmd,
1771 const char *method,

Callers

nothing calls this directly

Calls 9

json_get_memberFunction · 0.85
json_to_intFunction · 0.85
payment_logFunction · 0.85
getroutes_forFunction · 0.85
payment_give_upFunction · 0.85
json_strdupFunction · 0.50
command_still_pendingFunction · 0.50
amount_msat_eqFunction · 0.50
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected