| 2254 | } |
| 2255 | |
| 2256 | static struct command_result *channel_for_splice(struct command *cmd, |
| 2257 | struct channel_id *cid, |
| 2258 | struct channel **channel) |
| 2259 | { |
| 2260 | *channel = channel_by_cid(cmd->ld, cid); |
| 2261 | if (!*channel) |
| 2262 | return command_fail(cmd, SPLICE_UNKNOWN_CHANNEL, |
| 2263 | "Unknown channel %s", |
| 2264 | fmt_channel_id(tmpctx, cid)); |
| 2265 | |
| 2266 | if (!feature_negotiated(cmd->ld->our_features, |
| 2267 | (*channel)->peer->their_features, |
| 2268 | OPT_SPLICE)) |
| 2269 | return command_fail(cmd, SPLICE_NOT_SUPPORTED, |
| 2270 | "Peer does not support splicing"); |
| 2271 | |
| 2272 | if (!(*channel)->owner) |
| 2273 | return command_fail(cmd, SPLICE_WRONG_OWNER, |
| 2274 | "Channel is disconnected"); |
| 2275 | |
| 2276 | if (!streq((*channel)->owner->name, "channeld")) |
| 2277 | return command_fail(cmd, |
| 2278 | SPLICE_WRONG_OWNER, |
| 2279 | "Channel hasn't finished connecting or in " |
| 2280 | "abnormal owner state %s", |
| 2281 | (*channel)->owner->name); |
| 2282 | |
| 2283 | if ((*channel)->state != CHANNELD_NORMAL |
| 2284 | && (*channel)->state != CHANNELD_AWAITING_SPLICE) |
| 2285 | return command_fail(cmd, |
| 2286 | SPLICE_INVALID_CHANNEL_STATE, |
| 2287 | "Channel needs to be in normal or awaiting" |
| 2288 | " splice state but is in state %s", |
| 2289 | channel_state_name(*channel)); |
| 2290 | |
| 2291 | return NULL; |
| 2292 | } |
| 2293 | |
| 2294 | static struct command_result *param_channel_for_splice(struct command *cmd, |
| 2295 | const char *name, |
no test coverage detected