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

Function populate_private_layer

plugins/xpay/xpay.c:2088–2133  ·  view source on GitHub ↗

Create a layer with our payment-specific topology information */

Source from the content-addressed store, hash-verified

2086
2087/* Create a layer with our payment-specific topology information */
2088static struct command_result *populate_private_layer(struct command *cmd,
2089 struct payment *payment)
2090{
2091 struct request_batch *batch;
2092 bool all_failed;
2093 char *errors = NULL;
2094 struct out_req *req;
2095 struct command *aux_cmd;
2096
2097 /* Everything else is parented to a separate command, which
2098 * can outlive the one we respond to. */
2099 aux_cmd = aux_command(cmd);
2100 tal_steal(aux_cmd, payment);
2101 batch = request_batch_new(aux_cmd, NULL, log_payment_err, start_getroutes,
2102 payment);
2103 req = add_to_batch(aux_cmd, batch, "askrene-create-layer");
2104 json_add_string(req->js, "layer", payment->private_layer);
2105 send_payment_req(aux_cmd, payment, req);
2106
2107 for (size_t i = 0; i < tal_count(payment->route_hints); i++)
2108 add_routehint(batch, aux_cmd, payment, payment->route_hints[i]);
2109
2110 all_failed = tal_count(payment->paths) ? true : false;
2111 for (size_t i = 0; i < tal_count(payment->paths); i++) {
2112 char *err = add_blindedpath(tmpctx, batch,
2113 aux_cmd, payment, i,
2114 payment->paths[i],
2115 payment->payinfos[i]);
2116 if (!err) {
2117 all_failed = false;
2118 continue;
2119 }
2120 if (!errors)
2121 errors = err;
2122 else
2123 tal_append_fmt(&errors, ", %s", err);
2124 }
2125
2126 /* Nothing actually created yet, so this is the last point we don't use
2127 * "payment_give_up" */
2128 if (all_failed)
2129 return command_fail(aux_cmd, PAY_ROUTE_NOT_FOUND,
2130 "No usable blinded paths: %s", errors);
2131
2132 return batch_done(aux_cmd, batch);
2133}
2134
2135static struct command_result *
2136preapproveinvoice_succeed(struct command *cmd,

Callers 2

Calls 9

add_to_batchFunction · 0.85
send_payment_reqFunction · 0.85
add_routehintFunction · 0.85
add_blindedpathFunction · 0.85
tal_append_fmtFunction · 0.85
batch_doneFunction · 0.85
aux_commandFunction · 0.50
json_add_stringFunction · 0.50
command_failFunction · 0.50

Tested by

no test coverage detected