| 172 | } |
| 173 | |
| 174 | static struct command_result *do_fail(struct command *cmd, |
| 175 | struct splice_cmd *splice_cmd, |
| 176 | enum jsonrpc_errcode code, |
| 177 | const char *str TAKES) |
| 178 | { |
| 179 | struct out_req *req; |
| 180 | struct abort_pkg *abort_pkg; |
| 181 | size_t added; |
| 182 | |
| 183 | /* If we encounter an error, wetrun is canceled */ |
| 184 | splice_cmd->wetrun = false; |
| 185 | |
| 186 | plugin_log(cmd->plugin, LOG_DBG, |
| 187 | "splice_error(psbt:%p, splice_cmd:%p, str: %s)", |
| 188 | splice_cmd->psbt, splice_cmd, str ?: ""); |
| 189 | |
| 190 | abort_pkg = tal(cmd, struct abort_pkg); |
| 191 | abort_pkg->splice_cmd = tal_steal(abort_pkg, splice_cmd); |
| 192 | abort_pkg->str = tal_strdup(abort_pkg, str); |
| 193 | abort_pkg->code = code; |
| 194 | |
| 195 | req = jsonrpc_request_start(cmd, "abort_channels", |
| 196 | abort_get_result, forward_error, abort_pkg); |
| 197 | |
| 198 | added = 0; |
| 199 | json_array_start(req->js, "channel_ids"); |
| 200 | for (size_t i = 0; i < tal_count(splice_cmd->actions); i++) { |
| 201 | if (splice_cmd->actions[i]->channel_id) { |
| 202 | added++; |
| 203 | json_add_channel_id(req->js, NULL, |
| 204 | splice_cmd->actions[i]->channel_id); |
| 205 | } |
| 206 | } |
| 207 | json_array_end(req->js); |
| 208 | |
| 209 | if (!added) { |
| 210 | plugin_log(cmd->plugin, LOG_DBG, |
| 211 | "No channels were stfu'ed, skipping to unreserve" |
| 212 | " (psbt:%p)", splice_cmd->psbt); |
| 213 | return abort_get_result(cmd, NULL, NULL, NULL, abort_pkg); |
| 214 | } |
| 215 | |
| 216 | return send_outreq(req); |
| 217 | } |
| 218 | |
| 219 | static struct command_result *splice_error(struct command *cmd, |
| 220 | const char *methodname, |
no test coverage detected