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

Function notification_sendpay_failure

plugins/renepay/routetracker.c:482–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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