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

Function populate_private_layer

plugins/xpay/xpay.c:2157–2202  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2155
2156/* Create a layer with our payment-specific topology information */
2157static struct command_result *populate_private_layer(struct command *cmd,
2158 struct payment *payment)
2159{
2160 struct request_batch *batch;
2161 bool all_failed;
2162 char *errors = NULL;
2163 struct out_req *req;
2164 struct command *aux_cmd;
2165
2166 /* Everything else is parented to a separate command, which
2167 * can outlive the one we respond to. */
2168 aux_cmd = aux_command(cmd);
2169 tal_steal(aux_cmd, payment);
2170 batch = request_batch_new(aux_cmd, NULL, log_payment_err, start_getroutes,
2171 payment);
2172 req = add_to_batch(aux_cmd, batch, "askrene-create-layer");
2173 json_add_string(req->js, "layer", payment->private_layer);
2174 send_payment_req(aux_cmd, payment, req);
2175
2176 for (size_t i = 0; i < tal_count(payment->route_hints); i++)
2177 add_routehint(batch, aux_cmd, payment, payment->route_hints[i]);
2178
2179 all_failed = tal_count(payment->paths) ? true : false;
2180 for (size_t i = 0; i < tal_count(payment->paths); i++) {
2181 char *err = add_blindedpath(tmpctx, batch,
2182 aux_cmd, payment, i,
2183 payment->paths[i],
2184 payment->payinfos[i]);
2185 if (!err) {
2186 all_failed = false;
2187 continue;
2188 }
2189 if (!errors)
2190 errors = err;
2191 else
2192 tal_append_fmt(&errors, ", %s", err);
2193 }
2194
2195 /* Nothing actually created yet, so this is the last point we don't use
2196 * "payment_give_up" */
2197 if (all_failed)
2198 return command_fail(aux_cmd, PAY_ROUTE_NOT_FOUND,
2199 "No usable blinded paths: %s", errors);
2200
2201 return batch_done(aux_cmd, batch);
2202}
2203
2204static struct command_result *check_onion_budget(struct command *cmd,
2205 struct payment *payment);

Callers 1

check_onion_budgetFunction · 0.85

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