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

Function notification_sendpay_failure

plugins/renepay/routetracker.c:481–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479}
480
481struct command_result *notification_sendpay_failure(struct command *cmd,
482 const char *buf,
483 const jsmntok_t *params)
484{
485 plugin_log(pay_plugin->plugin, LOG_DBG,
486 "sendpay_failure notification: %.*s",
487 json_tok_full_len(params), json_tok_full(buf, params));
488
489 // enum jsonrpc_errcode errcode;
490 const jsmntok_t *sub = json_get_member(buf, params, "sendpay_failure");
491
492 struct routekey *key = tal_routekey_from_json(
493 tmpctx, buf, json_get_member(buf, sub, "data"));
494 if (!key)
495 plugin_err(pay_plugin->plugin,
496 "Unable to get routekey from sendpay_failure: %.*s",
497 json_tok_full_len(sub), json_tok_full(buf, sub));
498
499 struct payment *payment =
500 payment_map_get(pay_plugin->payment_map, key->payment_hash);
501
502 if (!payment) {
503 /* This sendpay is not linked to any route in our database, we
504 * skip it. */
505 return notification_handled(cmd);
506 }
507
508 struct routetracker *routetracker = payment->routetracker;
509 assert(routetracker);
510 struct route *route =
511 route_map_get(pay_plugin->pending_routes, key);
512 if (!route) {
513 route = tal_route_from_json(tmpctx, buf,
514 json_get_member(buf, sub, "data"));
515 if (!route)
516 plugin_err(pay_plugin->plugin,
517 "Failed to get route information from "
518 "sendpay_failure: %.*s",
519 json_tok_full_len(sub),
520 json_tok_full(buf, sub));
521 }
522
523 assert(route->result == NULL);
524 route->result = tal_sendpay_result_from_json(route, buf, sub,
525 route->shared_secrets);
526 if (route->result == NULL)
527 plugin_err(pay_plugin->plugin,
528 "Unable to parse sendpay_failure: %.*s",
529 json_tok_full_len(sub), json_tok_full(buf, sub));
530
531 if (route->result->status != SENDPAY_FAILED) {
532 /* FIXME shouldn't this be always SENDPAY_FAILED? */
533 const jsmntok_t *datatok = json_get_member(buf, sub, "data");
534 const jsmntok_t *statustok =
535 json_get_member(buf, datatok, "status");
536 const char *status_str = json_strdup(tmpctx, buf, statustok);
537
538 plugin_log(pay_plugin->plugin, LOG_UNUSUAL,

Callers

nothing calls this directly

Calls 11

json_get_memberFunction · 0.85
tal_routekey_from_jsonFunction · 0.85
tal_route_from_jsonFunction · 0.85
routefail_startFunction · 0.85
plugin_logFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
plugin_errFunction · 0.50
notification_handledFunction · 0.50
json_strdupFunction · 0.50

Tested by

no test coverage detected