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

Function payment_waitsendpay_finished

plugins/libplugin-pay.c:1487–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1485}
1486
1487static struct command_result *
1488payment_waitsendpay_finished(struct command *cmd, const char *buffer,
1489 const jsmntok_t *toks, struct payment *p)
1490{
1491 u8 *update;
1492
1493 assert(p->route != NULL);
1494
1495 p->end_time = time_now();
1496 p->result = tal_sendpay_result_from_json(p, buffer, toks);
1497
1498 if (p->result == NULL) {
1499 paymod_log(p, LOG_UNUSUAL,
1500 "Unable to parse `waitsendpay` result: %.*s",
1501 json_tok_full_len(toks),
1502 json_tok_full(buffer, toks));
1503 payment_set_step(p, PAYMENT_STEP_FAILED);
1504 payment_continue(p);
1505 return command_still_pending(cmd);
1506 }
1507
1508 payment_result_infer(p->route, p->result);
1509
1510 if (p->result->state == PAYMENT_COMPLETE) {
1511 payment_set_step(p, PAYMENT_STEP_SUCCESS);
1512 payment_continue(p);
1513 return command_still_pending(cmd);
1514 }
1515
1516 payment_chanhints_apply_route(p, true);
1517
1518 /* Tell gossipd, if we received an update */
1519 update = channel_update_from_onion_error(tmpctx, p->result->raw_message);
1520 if (update) {
1521 struct out_req *req;
1522 paymod_log(p, LOG_DBG,
1523 "Extracted channel_update %s from onionreply %s",
1524 tal_hex(tmpctx, update),
1525 tal_hex(tmpctx, p->result->raw_message));
1526 req = jsonrpc_request_start(p->plugin, NULL, "addgossip",
1527 payment_addgossip_success,
1528 payment_addgossip_failure, p);
1529 json_add_hex_talarr(req->js, "message", update);
1530 send_outreq(p->plugin, req);
1531 return command_still_pending(cmd);
1532 }
1533
1534 return payment_addgossip_success(cmd, NULL, NULL, p);
1535}
1536
1537static struct command_result *payment_sendonion_success(struct command *cmd,
1538 const char *buffer,

Callers

nothing calls this directly

Calls 15

time_nowFunction · 0.85
paymod_logFunction · 0.85
payment_set_stepFunction · 0.85
payment_continueFunction · 0.85
payment_result_inferFunction · 0.85
tal_hexFunction · 0.85
command_still_pendingFunction · 0.70
send_outreqFunction · 0.70

Tested by

no test coverage detected