Create a layer with our payment-specific topology information */
| 2086 | |
| 2087 | /* Create a layer with our payment-specific topology information */ |
| 2088 | static 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 | |
| 2135 | static struct command_result * |
| 2136 | preapproveinvoice_succeed(struct command *cmd, |
no test coverage detected