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

Function json_dev_forget_channel

lightningd/peer_control.c:3972–4038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3970}
3971
3972static struct command_result *json_dev_forget_channel(struct command *cmd,
3973 const char *buffer,
3974 const jsmntok_t *obj UNNEEDED,
3975 const jsmntok_t *params)
3976{
3977 struct peer *peer;
3978 struct channel *channel;
3979 struct short_channel_id *scid;
3980 struct channel_id *find_cid;
3981 struct dev_forget_channel_cmd *forget;
3982 bool *force;
3983
3984 if (!param_check(cmd, buffer, params,
3985 p_req("id", param_peer, &peer),
3986 p_opt("short_channel_id", param_short_channel_id, &scid),
3987 p_opt("channel_id", param_channel_id, &find_cid),
3988 p_opt_def("force", param_bool, &force, false),
3989 NULL))
3990 return command_param_failed();
3991
3992 forget = tal(cmd, struct dev_forget_channel_cmd);
3993 forget->cmd = cmd;
3994 forget->force = *force;
3995
3996 forget->channel = NULL;
3997 list_for_each(&peer->channels, channel, list) {
3998 /* Check for channel id first */
3999 if (find_cid) {
4000 if (!channel_id_eq(find_cid, &channel->cid))
4001 continue;
4002 }
4003 if (scid) {
4004 if (!channel->scid)
4005 continue;
4006 if (!short_channel_id_eq(*channel->scid, *scid))
4007 continue;
4008 }
4009 if (forget->channel) {
4010 return command_fail(cmd, LIGHTNINGD,
4011 "Multiple channels:"
4012 " please specify short_channel_id");
4013 }
4014 forget->channel = channel;
4015 }
4016 if (!forget->channel) {
4017 return command_fail(cmd, LIGHTNINGD,
4018 "No channels matching that peer_id%s",
4019 scid ? " and that short_channel_id" : "");
4020 }
4021
4022 if (channel_has_htlc_out(forget->channel) ||
4023 channel_has_htlc_in(forget->channel)) {
4024 return command_fail(cmd, LIGHTNINGD,
4025 "This channel has HTLCs attached and it is "
4026 "not safe to forget it. Please use `close` "
4027 "or `dev-fail` instead.");
4028 }
4029

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