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

Function json_openchannel_abort

lightningd/dual_open_control.c:2200–2253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2198}
2199
2200static struct command_result *
2201json_openchannel_abort(struct command *cmd,
2202 const char *buffer,
2203 const jsmntok_t *obj UNNEEDED,
2204 const jsmntok_t *params)
2205{
2206 struct channel_id *cid;
2207 struct channel *channel;
2208 u8 *msg;
2209
2210 if (!param(cmd, buffer, params,
2211 p_req("channel_id", param_channel_id, &cid),
2212 NULL))
2213 return command_param_failed();
2214
2215 channel = channel_by_cid(cmd->ld, cid);
2216 if (!channel)
2217 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
2218 "Unknown channel %s",
2219 type_to_string(tmpctx, struct channel_id,
2220 cid));
2221
2222 if (!channel->owner)
2223 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
2224 "Peer not connected");
2225
2226 if (!channel->open_attempt) {
2227 if (list_empty(&channel->inflights))
2228 return command_fail(cmd, FUNDING_STATE_INVALID,
2229 "Channel open not in progress");
2230 return command_fail(cmd, FUNDING_STATE_INVALID,
2231 "Sigs already exchanged, can't cancel");
2232 }
2233
2234 if (channel->open_attempt->cmd)
2235 return command_fail(cmd, FUNDING_STATE_INVALID,
2236 "Another openchannel command"
2237 " is in progress");
2238
2239 if (channel->openchannel_signed_cmd)
2240 return command_fail(cmd, FUNDING_STATE_INVALID,
2241 "Already sent sigs, waiting for peer's");
2242
2243 /* Mark it as aborted so when we clean-up, we send the
2244 * correct response */
2245 channel->open_attempt->aborted = true;
2246 channel->open_attempt->cmd = cmd;
2247
2248 /* Tell dualopend to fail this channel */
2249 msg = towire_dualopend_fail(NULL, "Abort requested");
2250 subd_send_msg(channel->owner, take(msg));
2251
2252 return command_still_pending(cmd);
2253}
2254
2255static struct command_result *
2256json_openchannel_bump(struct command *cmd,

Callers

nothing calls this directly

Calls 7

channel_by_cidFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
subd_send_msgFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected