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

Function json_dev_forget_channel

lightningd/peer_control.c:2960–3028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2958}
2959
2960static struct command_result *json_dev_forget_channel(struct command *cmd,
2961 const char *buffer,
2962 const jsmntok_t *obj UNNEEDED,
2963 const jsmntok_t *params)
2964{
2965 struct node_id *peerid;
2966 struct peer *peer;
2967 struct channel *channel;
2968 struct short_channel_id *scid;
2969 struct channel_id *find_cid;
2970 struct dev_forget_channel_cmd *forget = tal(cmd, struct dev_forget_channel_cmd);
2971 forget->cmd = cmd;
2972
2973 bool *force;
2974 if (!param(cmd, buffer, params,
2975 p_req("id", param_node_id, &peerid),
2976 p_opt("short_channel_id", param_short_channel_id, &scid),
2977 p_opt("channel_id", param_channel_id, &find_cid),
2978 p_opt_def("force", param_bool, &force, false),
2979 NULL))
2980 return command_param_failed();
2981
2982 forget->force = *force;
2983 peer = peer_by_id(cmd->ld, peerid);
2984 if (!peer) {
2985 return command_fail(cmd, LIGHTNINGD,
2986 "Could not find channel with that peer");
2987 }
2988
2989 forget->channel = NULL;
2990 list_for_each(&peer->channels, channel, list) {
2991 /* Check for channel id first */
2992 if (find_cid) {
2993 if (!channel_id_eq(find_cid, &channel->cid))
2994 continue;
2995 }
2996 if (scid) {
2997 if (!channel->scid)
2998 continue;
2999 if (!short_channel_id_eq(channel->scid, scid))
3000 continue;
3001 }
3002 if (forget->channel) {
3003 return command_fail(cmd, LIGHTNINGD,
3004 "Multiple channels:"
3005 " please specify short_channel_id");
3006 }
3007 forget->channel = channel;
3008 }
3009 if (!forget->channel) {
3010 return command_fail(cmd, LIGHTNINGD,
3011 "No channels matching that peer_id%s",
3012 scid ? " and that short_channel_id" : "");
3013 }
3014
3015 if (channel_has_htlc_out(forget->channel) ||
3016 channel_has_htlc_in(forget->channel)) {
3017 return command_fail(cmd, LIGHTNINGD,

Callers

nothing calls this directly

Calls 8

peer_by_idFunction · 0.85
channel_unsavedFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
channel_has_htlc_outFunction · 0.70
channel_has_htlc_inFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected