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

Function json_dev_forget_channel

lightningd/peer_control.c:4252–4318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4250}
4251
4252static struct command_result *json_dev_forget_channel(struct command *cmd,
4253 const char *buffer,
4254 const jsmntok_t *obj UNNEEDED,
4255 const jsmntok_t *params)
4256{
4257 struct peer *peer;
4258 struct channel *channel;
4259 struct short_channel_id *scid;
4260 struct channel_id *find_cid;
4261 struct dev_forget_channel_cmd *forget;
4262 bool *force;
4263
4264 if (!param_check(cmd, buffer, params,
4265 p_req("id", param_peer, &peer),
4266 p_opt("short_channel_id", param_short_channel_id, &scid),
4267 p_opt("channel_id", param_channel_id, &find_cid),
4268 p_opt_def("force", param_bool, &force, false),
4269 NULL))
4270 return command_param_failed();
4271
4272 forget = tal(cmd, struct dev_forget_channel_cmd);
4273 forget->cmd = cmd;
4274 forget->force = *force;
4275
4276 forget->channel = NULL;
4277 list_for_each(&peer->channels, channel, list) {
4278 /* Check for channel id first */
4279 if (find_cid) {
4280 if (!channel_id_eq(find_cid, &channel->cid))
4281 continue;
4282 }
4283 if (scid) {
4284 if (!channel->scid)
4285 continue;
4286 if (!short_channel_id_eq(*channel->scid, *scid))
4287 continue;
4288 }
4289 if (forget->channel) {
4290 return command_fail(cmd, LIGHTNINGD,
4291 "Multiple channels:"
4292 " please specify short_channel_id");
4293 }
4294 forget->channel = channel;
4295 }
4296 if (!forget->channel) {
4297 return command_fail(cmd, LIGHTNINGD,
4298 "No channels matching that peer_id%s",
4299 scid ? " and that short_channel_id" : "");
4300 }
4301
4302 if (channel_has_htlc_out(forget->channel) ||
4303 channel_has_htlc_in(forget->channel)) {
4304 return command_fail(cmd, LIGHTNINGD,
4305 "This channel has HTLCs attached and it is "
4306 "not safe to forget it. Please use `close` "
4307 "or `dev-fail` instead.");
4308 }
4309

Callers

nothing calls this directly

Calls 10

param_checkFunction · 0.85
short_channel_id_eqFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
channel_has_htlc_outFunction · 0.70
channel_has_htlc_inFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
command_still_pendingFunction · 0.70

Tested by

no test coverage detected