Create a layer with our payment-specific topology information */
| 2155 | |
| 2156 | /* Create a layer with our payment-specific topology information */ |
| 2157 | static 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 | |
| 2204 | static struct command_result *check_onion_budget(struct command *cmd, |
| 2205 | struct payment *payment); |
no test coverage detected