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

Function populate_private_layer

plugins/xpay/xpay.c:2099–2144  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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